示例#1
0
        public ActionResult Address(int id)
        {
            var dbPerson = this.COVID19Entities.People.First(x => x.Personid == id);

            if (dbPerson.Adress == null)
            {
                dbPerson.Adress = new Adress
                {
                };
                this.COVID19Entities.SaveChanges();
            }

            var dbAddress = dbPerson.Adress;

            var model = new NewPersonDtoStep2
            {
                PersonID = id,
                City     = dbPerson.Location,
                Comments = dbAddress.Comments,
                Dept     = dbAddress.Department,
                Floor    = dbAddress.Floor,
                Number   = dbAddress.Number,
                State    = dbAddress.Province,
                Street   = dbAddress.Street
            };

            return(View(model));
        }
示例#2
0
        public ActionResult Address(NewPersonDtoStep2 model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var dbPerson = this.COVID19Entities.People.First(x => x.Personid == model.PersonID);
            var address  = dbPerson.Adress;

            address.Street     = model.Street;
            address.Number     = model.Number;
            address.Floor      = model.Floor;
            address.Department = model.Dept;
            address.Comments   = model.Comments;
            address.EffectDate = DateTime.Now;
            address.Location   = model.City;
            dbPerson.Location  = model.City;

            this.COVID19Entities.SaveChanges();

            return(RedirectToAction("Contact", "Person", new { id = dbPerson.Personid }));
        }