IT/Software career thread: Invert binary trees for dollars.

Lendarios

Trump's Staff
<Gold Donor>
19,360
-17,424
Now lets update the Database. FINALLY

on package manger type
Update-DAtabase -verbose

This will lets yousee teh SQL that will be applied to the DAtabase


1524498647215.png


Here is the DAtabse view from SSMS
1524498748160.png


I want you to look at the Column and the class you created "Salary" and look at how they map 1-1. Look at the data type, the nullables, the bits vs booleans, the length.

Questions?
 

Lendarios

Trump's Staff
<Gold Donor>
19,360
-17,424
ok now we have tied the Code with SQL, now lets show some data on the screen. Right click on Controllers folder, "Add new controller"


1524500124063.png


then
1524500257227.png


Then f5 and navigate to teh following URL on your PC
the port number will be diferent for everyone

http://localhost:51252/Salaries/index

Website/Controller/Action
Salaries is the controller you created, the word controlled is not used on the mapping
Index is the action that you are requesting.

Then stop the website and goto

SalaryController.cs

A controller is a cop, it handles the directions of the actions but not the actions themselves. So If you dont want an action DONT have it there. Im assuming you want to delete (Create, Edit and Delete)
Remove those methods.
 

Lendarios

Trump's Staff
<Gold Donor>
19,360
-17,424
Here is where your HTML Knowledge comes in. Feel free to style out the following files
1524501157330.png


Those are the files that contain the Html code.

So it works like this. Controller recieves an action. Controller gathers the data from the model and sends it to the view for rendering.

How does the view knows the data type? Because of the
Code:
@model IEnumerable<MachineReport.Models.Salary>
This tells the view that the model on this case is a list of Salary objects
 

Lendarios

Trump's Staff
<Gold Donor>
19,360
-17,424
also remove any view associated with a deleted action. Dont leave a view for delete, if there is no action for delete.
 

Lendarios

Trump's Staff
<Gold Donor>
19,360
-17,424
Ok now add the styles that you need.


Try making the row red if amount > 1000, else green
Hint the changes are on the view with class="___" and "if statements"
 

Lendarios

Trump's Staff
<Gold Donor>
19,360
-17,424
Create a css class for the red background, create another ccs class for the green background

Put logic on the razor line that builds the TD to swap one with the other depending on the amount.
 

Lendarios

Trump's Staff
<Gold Donor>
19,360
-17,424
How to use ? : if statements with Razor and inline code blocks

Code:
<td class="@(item.Amount>1000? "REEEEEEEd-class" : "green-class" )">
            @Html.DisplayFor(modelItem => item.EffectiveOn)
        </td>

anything you type after @ on a razor view its it considered C# code, so you can add logic in there.


Take a look at that view the index.cshtml do you understand everything is doing?

a razor view a *.cshtml is NOT send down to the client as is, the razor engine process it and then the HTML is send down.
 

Big_w_powah

Trakanon Raider
1,887
750
I think so.

Code:
  <tr>
        <th>
            @Html.DisplayNameFor(model => model.Amount)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.FixedLenth)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.VeryLongString)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.EffectiveOn)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Inactive)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Deleted)
        </th>
        <th></th>
    </tr>

I see this as creating headers, using the column row it grabs from the model,

and

Code:
@foreach (var item in Model) {
    
    <tr>
        <td class="@(item.Amount>1000? "RedBackground" : "GreenBackground")">
            @Html.DisplayFor(modelItem => item.Amount)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.FixedLenth)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.VeryLongString)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.EffectiveOn)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Inactive)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Deleted)
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { id=item.SalaryId }) |
            @Html.ActionLink("Details", "Details", new { id=item.SalaryId })
          
        </td>
    </tr>
}

I see this as grabbing each of the rows, and displaying that data.
 

Lendarios

Trump's Staff
<Gold Donor>
19,360
-17,424
correct. also that teh language is not pure html, its razor. A mixture of them. Also there are helpers tha will spit out HTML for you such as
" @Html.DisplayFor(modelItem => item.Deleted) "
However that is not the only way to diplay them. you could have pretty much use an actual html <input type="checkbox" value="@item.Deleted" > and it would have work.

but who has time to type all that right?
 

Lendarios

Trump's Staff
<Gold Donor>
19,360
-17,424
sweet now, If another developer is going to feed data into your system. you can ask him if he prefer one table oe many table.

If it is one table, think about all the fields you talk about , then make a class with those fields. Its ok if they are denormalize. Create the class and do the whole migration again,
Then you have your dashboard.
 
  • 1Like
Reactions: 1 user

Asshat wormie

2023 Asshat Award Winner
<Gold Donor>
16,820
30,964
I saw this thread was very active and got excited. What a snooze fest :(
 

Deathwing

<Bronze Donator>
16,395
7,396
It seems those two have solved their problem, so I have a question for the developers(so, most people?) of this thread. What's your criteria for a good software test engineer. I don't mean, write me a job req. But what is that person doing well for you think they are doing their job correctly? Followup question: do you think those expectations are reasonable?

No wrong answers, say whatever you want, I'm not going to spring some gotcha. My rant from last week is still "unresolved". My boss has been on vacation interim, so I haven't gone to him to complain yet. And I really hate just complaining, I like to propose solutions if possible. So, if my complaint is that I think product architect's expectations are unrealistic, I'd like to propose more realistic/different ones.

Feeling like you're not meeting expectations(despite getting promotions and good reviews) is much more insidious and undermining than one would expect. If it were humanly possible, I suspect he'd just run the whole department himself.