public async Task <IActionResult> PostGroup([FromBody] GroupCreatingDTO groupCreatingDTO) { Group group; try { group = await Task.Run(() => _mapper.Map <Group>(groupCreatingDTO)); Film movie = new Film(); await Task.Run(() => { _groupsService.AddGroup(group, UserService.GetLoggedInUserId(this)); }); } catch (ArgumentException ex) { return(BadRequest(BaseStatusDto.CreateErrorDto(ex.Message))); } catch (Exception ex) { return(BadRequest(BaseStatusDto.CreateErrorDto(ex.Message))); } Group newGroup = _groupsService.GetGroup(group.Id); return(Ok(_mapper.Map <GroupViewDTO>(newGroup))); }
public async Task <IActionResult> PutGroup([FromRoute] int id, [FromBody] GroupCreatingDTO groupCreatingDTO) { try { Group group = _mapper.Map <Group>(groupCreatingDTO); await Task.Run(() => _groupsService.UpdateGroup(id, group)); } catch (ArgumentException ex) { return(BadRequest(BaseStatusDto.CreateErrorDto(ex.Message))); } catch (Exception ex) { return(BadRequest(BaseStatusDto.CreateErrorDto(ex.Message))); } return(Ok(BaseStatusDto.CreateSuccessDto())); }