Beispiel #1
0
        public async Task <NoContentResult> UpdateUserRole(
            [FromBody] VmProjectUserRole userRole)
        {
            await _userRolesService.Update(userRole);

            return(NoContent());
        }
Beispiel #2
0
        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));
        }
Beispiel #3
0
        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);
            }
        }