private void UpdateUserAddres(Address addres, UpdateUserAddressCommand command) { addres.City = command.City; addres.Street = command.Street; addres.HomeNumber = command.HomeNumber; addres.FlatNumber = command.FlatNumber; addres.PostCode = command.PostCode; }
public async Task <ActionResult <CommandResult <int> > > UpdateAddress([FromBody] UpdateUserAddressCommand command) { var result = await _mediator.Send(command); if (result.IsSuccess) { return(Ok(result.Payload)); } return(BadRequest(result.FailureReason)); }
public void Handle(UpdateUserAddressCommand command) { using (var dbContext = new UserAccountDataContext()) { User user = dbContext.Users.SingleOrDefault(u => u.Id == command.UserId); if (user == null) { throw new ServerSideException("Ups, something went wrong! Refresh page and try agine"); } UpdateUserAddres(user.Address, command); dbContext.SaveChanges(); } }
public ActionResult ChangeAddress(UpdateUserAddressCommand command) { HandleCommand(command, Json("User address updated")); return(RedirectToAction("Index")); }