public IActionResult AddG([FromBody] GroupAddModel model) { GroupAddReturn ret = new GroupAddReturn(); try { if (!ModelState.IsValid) { ret.ErrorInformation.UserInformation = "An error has occured"; return(Ok(Json(ret))); } if (_groupDataService.IsUrlKeyAlreadyExist(model.Urlkey)) { ret.ErrorInformation.UserInformation = "There is already a group with id " + model.Urlkey; return(Ok(Json(ret))); } Group groupToAdd = new Group() { DateUtcAdd = DateTime.Now, DateUtcModified = DateTime.Now, Description = model.Description, Name = model.Name, UrlKey = model.Urlkey }; _groupService.Add(groupToAdd); ret.IsActionSucceed = true; ret.SuccessInformation = new SuccessReturnInformation() { RedirectUrl = "group/" + model.Urlkey, SuccessType = SuccessType.Redirect, UserInformation = "The new group is added", }; return(Ok(Json(ret))); } catch (Exception ex) { ret.ErrorInformation.UserInformation = "An error has occured -> " + ex.Message; return(Ok(Json(ret))); } }