public async Task<UserAccount> UpdateAsync(UserAccount userAccount) { using (var uow = _uowFac.Create()) { uow.UserAccountRepository.Update(userAccount); await uow.SaveChangesAsync(); return userAccount; } }
public async Task<UserAccount> InsertAsync(UserAccount userAccount) { using (var uow = _uowFac.Create()) { userAccount.Id = Guid.NewGuid().ToString(); uow.UserAccountRepository.Insert(userAccount); await uow.SaveChangesAsync(); return userAccount; } }
public async Task<IHttpActionResult> PostUserAccount(UserAccount userAccount) { try { if (!ModelState.IsValid) return BadRequest(ModelState); var result = await _userAccountService.InsertAsync(userAccount); return Ok(result); } catch (Exception) { throw; } }
public async Task<IHttpActionResult> PutUserAccount(UserAccount userAccount) { try { if (!ModelState.IsValid) return BadRequest(ModelState); if (String.IsNullOrEmpty(userAccount.Id)) return BadRequest(); var result = await _userAccountService.UpdateAsync(userAccount); return Ok(result); } catch (Exception) { throw; } }