public ActionResult Create([Bind(Include = "id_group,group_name,numeric_group_name")] Groups groups)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.Type = "create";
                return(View(groups));
            }

            try
            {
                groupsService.Add(groups);
                TempData["Status"] = "success";
                TempData["Msg"]    = "Nowa grupa została dodana!";
            }
            catch (Exception e)
            {
                TempData["Status"] = "invalid";
                TempData["Msg"]    = "Nie udało się dodać nowej grupy!";
            }

            return(RedirectToAction("List"));
        }
Exemple #2
0
        public IActionResult Post([FromBody] GroupsVo groupsVo)
        {
            try
            {
                var groupsEntity = _groupsConverter.Parse(groupsVo);

                if (groupsEntity == null)
                {
                    return(BadRequest());
                }
                var ret = _groupsService.Add(groupsEntity);

                return(Ok(ret));
            }
            catch (ArgumentNullException e)
            {
                return(NotFound(e.Message));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message + " | " + e.InnerException.Message));
            }
        }
 public Group Add(Group group)
 {
     _logger.LogTrace("######### Helloooooo from {decoratedMethod} #########", nameof(Add));
     return(_inner.Add(group));
 }
        public IActionResult CreateReally(GroupViewModel model)
        {
            _groupsService.Add(model.ToServiceModel());

            return(RedirectToAction("Index"));
        }