Example #1
0
 public IActionResult Create([FromBody] Group group)
 {
     (bool result, string message) = _groupsService.AddGroup(group.Name, group.GroupType);
     if (result)
     {
         return(Ok());
     }
     return(BadRequest(message));
 }
Example #2
0
 public HttpResponseMessage AddGroup([FromBody] Groups group)
 {
     {
         if (ModelState.IsValid)
         {
             _service.AddGroup(group);
             return(new HttpResponseMessage(HttpStatusCode.OK));
         }
         else
         {
             return(new HttpResponseMessage(HttpStatusCode.BadRequest));
         }
     }
 }
Example #3
0
        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!"));
        }
Example #5
0
 /// <summary>
 /// Додає групу
 /// </summary>
 /// <param name="groupDto">Екземпляр групи</param>
 public void AddGroup(GroupsDtoModel groupDto) => groupsService.AddGroup(groupDto);