public async Task <IActionResult> Post([FromBody] GroupRequest groupRequest) { if (groupRequest == null) { return(BadRequest()); } var model = groupRequest.ToModel(); var newGroup = await _groupRepository.PostAsync(model); return(Ok(GroupResponse.Create(newGroup, new List <StudentModel>()))); }
public async Task <IActionResult> PutGroup([FromBody] GroupRequest groupRequest) { if (groupRequest == null || groupRequest.Id < 0) { return(BadRequest()); } var changedGroup = await _groupRepository.PutAsync(groupRequest.ToModel()); if (changedGroup == null) { return(NotFound()); } var response = GroupResponse.Create(changedGroup, await _studentRepository.GetStudentsByGroupIdAsync(changedGroup.Id)); return(Ok(response)); }