public IHttpActionResult Post(MeetCreate meet) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateMeetService(); if (!service.CreateMeet(meet)) { return(InternalServerError()); } return(Ok()); }
public bool CreateMeet(MeetCreate model) { var entity = new Meet() { OwnerID = _userID, LocationOfMeet = model.LocationOfMeet, DescriptionOfMeet = model.DescriptionOfMeet, DateOfMeet = model.DateOfMeet, DateCreated = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { ctx.Meets.Add(entity); return(ctx.SaveChanges() == 1); }; }
public ActionResult Create(MeetCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateMeetService(); if (service.CreateMeet(model)) { TempData["SaveResult"] = "Your Meet Has Successfully Been Created!"; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Meet Could Not Be Made"); return(View(model)); }