public HttpResponseMessage Create(Facade.GroupPost topic) { return(ProcessPost(() => { var instance = topic.ToModel(); createGroupCommand.Execute(instance); return ResourceLocation.OfGroup(instance.Id.Value); })); }
public IActionResult Post([FromBody] CreateGroupModel newGroup, [FromServices] ICreateGroupCommand createGroupCommand) { if (ModelState.IsValid) { var storedGroup = createGroupCommand.Execute(newGroup); return(Created(Request.Path.Value + "/" + storedGroup.Id, storedGroup)); } else { return(BadRequest("Something went wrong")); } }
public ActionResult Create(GroupCreateModel model) { try { var group = new Group { Name = model.Name, Description = model.Description, ParentId = model.ParentId == null ? new Identity?() : new Identity(model.ParentId) }; createGroupCommand.Execute(group); return(RedirectToAction("Index")); } catch (Exception e) { ModelState.AddModelError(Guid.NewGuid().ToString(), e); } model.GroupList = GetGroupList(); return(View(model)); }