public async Task <ActionResult <Address> > PostAddress(Address address) { if (!ModelState.IsValid) { return(BadRequest()); } Address a = new Address { AddressType = address.AddressType, City = address.City, Complement = address.Complement, Location = address.Location, Neighborhood = address.Neighborhood, Number = address.Number, PersonId = address.PersonId, State = address.State }; await _addressesRepository.CreateAddressAsync(a); return(StatusCode(201)); }
public async Task <IActionResult> Create([Bind("Id,Location,Number,Complement,AddressType,Neighborhood,City,State,PersonId")] CreateAddressViewModel address) { if (ModelState.IsValid) { Address a = new Address { AddressType = address.AddressType, City = address.City, Complement = address.Complement, Location = address.Location, Neighborhood = address.Neighborhood, Number = address.Number, PersonId = address.PersonId, State = address.State }; await _addressesRepository.CreateAddressAsync(a); return(RedirectToAction(nameof(Index))); } ViewData["PersonId"] = new SelectList(await _peopleRepository.GetPeopleAsync(), "Id", "Nome", address.PersonId); return(View(address)); }