philanderson888 / c-sharp

A repository for teaching C#
MIT License
2 stars 1 forks source link

Adding new database item to Personal Project #21

Closed philanderson888 closed 4 years ago

philanderson888 commented 4 years ago

Update the database for my family management system to include a new field

Update field on azure

Update controller

Update view

philanderson888 commented 4 years ago

Log into Azure Find the database App is MVCFamilyApp2019102003 Resource Group is MVCFamilyApp201910 Database is FamilyDatabase04

philanderson888 commented 4 years ago

Find Query Editor Table is DailyLogs Add field SQL alter command alter table [dbo].[DailyLogs] add NbrGrps int null

philanderson888 commented 4 years ago

Now add to application

Firstly the model

Existing model is as such

    public class DailyLog
    {
        public int DailyLogId { get; set; }
        [Display(Name = "Date")]
        [DataType(DataType.Date)]
        [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MM/yyyy}")]
        public DateTime LogDate { get; set; }

        public String Comments { get; set; }
        public bool UpOnTime { get; set; }
        public bool StayedUp { get; set; }
        public bool MadeGym { get; set; }
        public bool PrWthFam { get; set; }
        public bool PrWthZ { get; set; }
        public bool CrsPryPhoto { get; set; }
        public bool PhilPryPhoto { get; set; }
        public bool CrsDeskPhoto { get; set; }
        public int NbrSns { get; set; }
    }
philanderson888 commented 4 years ago

New class is

    public class DailyLog
    {
        public int DailyLogId { get; set; }
        [Display(Name = "Date")]
        [DataType(DataType.Date)]
        [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MM/yyyy}")]
        public DateTime LogDate { get; set; }

        public String Comments { get; set; }
        public bool UpOnTime { get; set; }
        public bool StayedUp { get; set; }
        public bool MadeGym { get; set; }
        public bool PrWthFam { get; set; }
        public bool PrWthZ { get; set; }
        public bool CrsPryPhoto { get; set; }
        public bool PhilPryPhoto { get; set; }
        public bool CrsDeskPhoto { get; set; }
        public int NbrSns { get; set; }
        public int NbrGrps { get; set; }
        public bool GymCardio { get; set; }
        public bool GymWeights { get; set; }
        public bool GymSprints { get; set; }
        public bool GymChest { get; set; }
        public bool GymBack { get; set; }
        public bool GymLegs { get; set; }
        public bool GymBicep { get; set; }
        public bool GymTricep { get; set; }
        public bool GymShoulders { get; set; }
        public bool GymClass { get; set; }
        public bool GymDips { get; set; }
        public bool GymPullUps { get; set; }
        public bool GymPushUps { get; set; }
    }
philanderson888 commented 4 years ago

This incorporates changes from issue 22 also which is adding in gym fields ie

https://github.com/philanderson888/c-sharp/issues/22

philanderson888 commented 4 years ago

Updating the Views

I've manually updated all of the views - Index, Edit, Create, Delete, Details

philanderson888 commented 4 years ago

Test - does it work?

let's see if the application still works! Let's take a risk and publish the application live and see if it works or not.
Chances are slim but I've only made some trivial changes so there might be a chance it just works out of the box!

philanderson888 commented 4 years ago

No - it does not work so I'm going to have to do some more work! I could put it into development mode in Azure or I could update the local database. Let's try Azure! Put app into development mode

philanderson888 commented 4 years ago

portal.azure.com find the app service click on Configuration add new setting ASPNETCORE_ENVIRONMENT = Development

philanderson888 commented 4 years ago

After now updating the controller and the individual views, this item is now closed!