public async Task <NoContentResult> UpdateUserRole( [FromBody] VmProjectUserRole userRole) { await _userRolesService.Update(userRole); return(NoContent()); }
public async Task <VmProjectUserRole> Add(VmProjectUserRole viewModel) { var model = _vmConverter.ToModel(viewModel); _dataContext.Entry(model).State = EntityState.Added; await _dataContext.SaveChangesAsync(); return(_vmConverter.ToViewModel(model)); }
public async Task Update(VmProjectUserRole viewModel) { var model = _vmConverter.ToModel(viewModel); try { var isExist = await IsExist(viewModel.ProjectId, viewModel.UserId); _dataContext.Entry(model).State = isExist ? EntityState.Modified : EntityState.Added; await _dataContext.SaveChangesAsync(); } catch (Exception) { throw new HttpResponseException(HttpStatusCode.BadRequest); } }