Beispiel #1
0
        public ActionResult Create(Person newPerson)
        {
            try
            {
                //Need to check to make sure it is a valid number and it isn't already taken

                //Get the next Number
                string lastNum = Person.getNextNumber(_contextDB);
                Person.LastNumber = lastNum;

                newPerson.Number = lastNum;


                //Insert new person into database
                _contextDB.Add(newPerson);
                _contextDB.SaveChanges();

                //return to the details page of the person we just entered
                return(RedirectToAction(nameof(Details), new { id = newPerson.Id }));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Create(Corporate newCorporation)
        {
            try
            {
                //Get the next Number
                string lastNum = Corporate.getNextNumber(_contextDB);;
                Person.LastNumber = lastNum;

                Corporate.LastNumber = lastNum;

                newCorporation.Number = lastNum;

                // insert logic for adding a new corporate tax
                _contextDB.Add(newCorporation);
                _contextDB.SaveChanges();

                // returning the details page of the new corporate tax
                return(RedirectToAction(nameof(Details), new { id = newCorporation.Id }));
            }
            catch
            {
                return(View());
            }
        }