public ActionResult CreateEvent(EventCreateViewModel model) { if (ModelState.IsValid) { Event eEvent = new Event() { CreateUserId = model.UserId, CreateDateTime = DateTime.Now, StartDate = model.Start.GetValueOrDefault().Date, StartDateTime = model.Start.GetValueOrDefault(), EndDate = model.End.GetValueOrDefault().Date, EndDateTime = model.End.GetValueOrDefault(), IsActive = true, Location = model.Location, Note = model.Note, Title = model.Title }; RavenSession.Store(eEvent); RavenSession.SaveChanges(); ViewBag.Message = "Successfully added"; model = new EventCreateViewModel(); model.Events = RavenSession.Query<Event>().ToList(); return View(model); } model.Events = RavenSession.Query<Event>().ToList(); return View(); }
public ActionResult Create(EventCreateViewModel model) { if (ModelState.IsValid) { var newEvent = new Event() { CreateUserId = model.UserId, CreateDateTime = DateTime.Now, StartDateTime = model.Start.GetValueOrDefault(), StartDate = model.Start.GetValueOrDefault().Date, EndDateTime = model.End.GetValueOrDefault(), EndDate = model.End.GetValueOrDefault().Date, Location = model.Location, Note = model.Note, Title = model.Title, IsActive = true }; RavenSession.Store(newEvent); RavenSession.SaveChanges(); return Json(new { Success = true, Message = "Success" }, JsonRequestBehavior.DenyGet); } return Json(new { Success = false, Message = "There was a problem trying to save the event" }); }