public async Task <ActionResult> UpsertResidentAccount(AccountViewModel avm) { avm.User.Role = avm.User.RolesEnum.ToString(); User user = new User() { Id = avm.User.Id, FirstName = avm.User.FirstName, LastName = avm.User.LastName, Username = avm.User.Username, Role = avm.User.RolesEnum.ToString() }; Resident resident = await _reRepo.GetAsync(SD.ResidentAPIPath, avm.User.ResidentId, HttpContext.Session.GetString("JWToken")); if (resident != null) { resident.PrimaryContact.Email = avm.User.Username; await _reRepo.UpdateAsync(SD.ResidentAPIPath + avm.User.ResidentId, resident, HttpContext.Session.GetString("JWToken")); } await _accRepo.UpdateAsync(SD.AccountAPIPath + user.Id, user, HttpContext.Session.GetString("JWToken")); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Update(int id, [FromBody] UpdateResidentDTO putObject) { var resident = await _repository.GetByIdAsync <Resident>(id); if (resident == null) { return(NotFound("Resident not found")); } resident.FullName = putObject.FullName; resident.BirthDate = putObject.BirthDate; resident.Cpf = putObject.Cpf; resident.Email = putObject.Email; resident.Telephone = putObject.Telephone; resident.ApartmentId = putObject.ApartmentId; await _repository.UpdateAsync <Resident>(resident); return(Ok()); }
public async Task PostUpdateResident(Resident obj) { await _reRepo.UpdateAsync(SD.ResidentAPIPath + obj.Id, obj, HttpContext.Session.GetString("JWToken")); }