public IHttpActionResult CreateGroup([FromBody] GroupCreateBindingModels model) { if (model == null) { return this.BadRequest("Model cannot be null (no data in request)"); } if (!this.ModelState.IsValid) { return this.BadRequest(this.ModelState); } else { var currentUserId = this.User.Identity.GetUserId(); var currentUser = this.Data.Users.Find(currentUserId); Group group = new Group(); group.Name = model.Name; group.WallGroup = new WallGroup(); group.CreatorId = currentUserId; currentUser.Groups.Add(group); this.Data.SaveChanges(); return Ok(new GroupsGetViewModels(group)); } }
public GroupsGetViewModels(Group group) { this.Name = group.Name; this.Id = group.Id; }