public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,ImagePath,ImageData,Email,AddressOne,AddressTwo,City,State,ZipCode,PhoneNumber,Created")] AddressPerson addressPerson)
        {
            if (id != addressPerson.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(addressPerson);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AddressPersonExists(addressPerson.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(addressPerson));
        }
        public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,ImagePath,ImageData,Email,AddressOne,AddressTwo,City,State,ZipCode,PhoneNumber,Created")] AddressPerson addressPerson)
        {
            if (ModelState.IsValid)
            {
                addressPerson.Created = DateTimeOffset.Now;
                _context.Add(addressPerson);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(addressPerson));
        }
Esempio n. 3
0
        private void LoadFromModel(AddressPerson model)
        {
            AddressId = model.AddressId;
            PersonId  = model.PersonId;

            if (model.Address != null)
            {
                Address = new AddressModel(model.Address);
            }

            if (model.Person != null)
            {
                Person = new PersonModel(model.Person);
            }
        }
Esempio n. 4
0
 public AddressPersonModel(AddressPerson model) : base(model)
 {
     LoadFromModel(model);
 }