Skip to content

A system for managing forms. Developed in Visual Studio with C#.NET MVC and a MSSQL database. Only part entire code. With examples of improved code (UI in English).

Notifications You must be signed in to change notification settings

StefLove/EoS-original-Partial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

FormSystem_Partial

A system for managing forms. Developed in C#.NET MVC.
LINQ is used to update (i.e. not SQL) the database which is a MSSQL one.
Only this part of the code is free to view.
If you want to view more code or buy the system, please contact me.
Now I have improved the system by simplifying the code, this code here as You might see, needs more improvements.
I am now converting this improved code to C#.NET Core Razor Pages which makes the whole system much simpler.
UI in English.

The code is a good example of the programming principles of
1) ViewModel:
    in https://github.com/StefLove/FormSystem_Partial/blob/master/EoS/Models/IdeaCarrier/Startup.cs
    row 166 and below.
2) virtual:
    see https://github.com/StefLove/FormSystem_Partial/blob/master/EoS/Controllers/StartupsController.cs
    rows 719 and 720 (virtual takes care of that modification in the database method SaveChanges).
3) Inheritence:
    Can also be used in ViewModels (and in Models of course !).
    In https://github.com/StefLove/FormSystem_Partial/blob/master/EoS/Models/IdeaCarrier/Startup.cs
    row 284 and below.
    (What do you do if you want more than 1 database table of the same model in ORM ? Simply use inheretence !)
4) No unnecessary updates of the database:
    in https://github.com/StefLove/FormSystem_Partial/blob/master/EoS/Controllers/StartupsController.cs
    Database method SaveChanges (rows 255,331,1066,1133,1175,1202,1239,1273) and
    EntityState method Modified (rows 327,1065,1132,1201,1238,1272).
    are only used when really necessary !
5) Code easier to read:
    in https://github.com/StefLove/FormSystem_Partial/blob/master/EoS/Controllers/StartupsController.cs
    using the pattern: var X = GetX(/*parameters*/). Rows 363,388,392.
    No use of Viewbags (or ViewData), except in Index (rows 28-114) (and ProjectDetails (rows 118-156),
    using ViewModels with SelectLists instead.
    Rows 202,204,267,269,358,367,369,378,394,396.
6) LINQ and ORM:
    e.g. in https://github.com/StefLove/FormSystem_Partial/blob/master/EoS/Controllers/StartupsController.cs
    e.g. Rows 56,61,76,81,133,149.
7) Razor:
    e.g. in the cshtml files: https://github.com/StefLove/FormSystem_Partial/tree/master/EoS/Views

Major differences between the old and the new code
Have a look at https://github.com/StefLove/FormSystem_Partial/edit/master/EoS/Controllers/StartupsController_bad_old_code
1) That horrible [Bind(Include = "...")] (which makes the code less readable and has that problem with overposting attacks)
    rows 162, 254 (really awful!).
2) ViewBag after ViewBag (horrible too)
    139-151, 197-207, 223-233, 294-303
Compare with new code https://github.com/StefLove/FormSystem_Partial/blob/master/EoS/Controllers/StartupsController.cs
Most of the improvements:
1) Instead of [Bind(Include = "...")] ViewModels are used:
    The code is much easier to read and follow now.
    Rows 216-272, 316-347, 349-403
2) Viewbags are only used in Index (and in ProjectDetails, but that is easy to change):
    Rows 28-114, 118-156 (see also above under 5)).
3) Names has been renamed and is now easier to understand because they follow a logic:
    Details (old code row 110) to ProjectDetails (row 118)
    Create (old code rows 137, 162) to AddNewProject (rows 196, 216)
    Edit (old code rows 214, 254) is renamed to ProjectForm (rows 277, 316)
    Delete (old code row 362) to RemoveProject (row 1144)
4) This new code is more effective and thus runs faster mainly due to the splitting of the ProjectForm into 5 parts:
    Have a look at the files containing the word ProjectForm in
    https://github.com/StefLove/FormSystem_Partial/tree/master/EoS/Views/Startups
5) Unnessary code deleted:
    in https://github.com/StefLove/FormSystem_Partial/blob/master/EoS/Controllers/StartupsController_bad_old_code
    e.g. PopulateAssignedCheckBoxsData rows 300,585-647.
6) The code is made easier to find (and thus to read):
    Rows 400-438 in the old code, replaced with better code: rows 818-856 in the new code.
    Rows 525-528,547-556 in the old code, replaced with better code: rows 425-443 in the new code.

    The result of these improvements of mine is that my code is faster and more dynamic than the old one.

Now you see that the developer who wrote the bad code was'nt that very skilled (more of a frontend developer),
despite an education of 5 years in IT technology and programming !
You just can't just be a plain developer, you must be an excellent developer who delivers code that works and looks nice !

An improved version of this system is published at http://eos.enabling.se

Stefan
Stockholm
Sweden

About

A system for managing forms. Developed in Visual Studio with C#.NET MVC and a MSSQL database. Only part entire code. With examples of improved code (UI in English).

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages