public IActionResult Create([FromBody] Group group) { (bool result, string message) = _groupsService.AddGroup(group.Name, group.GroupType); if (result) { return(Ok()); } return(BadRequest(message)); }
public HttpResponseMessage AddGroup([FromBody] Groups group) { { if (ModelState.IsValid) { _service.AddGroup(group); return(new HttpResponseMessage(HttpStatusCode.OK)); } else { return(new HttpResponseMessage(HttpStatusCode.BadRequest)); } } }
public IActionResult AddGroup(string groupName) { if (string.IsNullOrEmpty(groupName)) { return(BadRequest()); } var groups = _groupsService.AddGroup(groupName); if (!groups) { return(NotFound()); } return(Ok(groups)); }
public async Task <IActionResult> AddGroup(Group group) { if (await _groupsService.GroupExists(group)) { return(BadRequest("The group you entered already exists!")); } _groupsService.AddGroup(group); if (await _groupsService.SaveChangesInContext()) { return(NoContent()); } return(BadRequest("Something went wrong!")); }
/// <summary> /// Додає групу /// </summary> /// <param name="groupDto">Екземпляр групи</param> public void AddGroup(GroupsDtoModel groupDto) => groupsService.AddGroup(groupDto);