public ActionResult AddEvent(long? id) { var model = new EventViewModel(); if (id != null) { model.Event = eventService.GetEventById(id.Value).MapFromServerToClient(); } locationsList = model.Locations = locationService.GetAllLocations().Select(x => x.MapFromServerToClient()); ViewBag.MessageVM = TempData["Message"] as MessageViewModel; return View(model); }
public ActionResult AddEvent(EventViewModel model) { if (model.Event.EventId == 0) { model.Event.RecCreatedDate = DateTime.Now; model.Event.RecCreatedBy = Session["UserID"].ToString(); } model.Event.RecLastUpdatedBy = Session["UserID"].ToString(); model.Event.RecLastUpdatedDate = DateTime.Now; if (eventService.AddUpdateEvents(model.Event.MapFromClientToServer())) { TempData["Message"] = new MessageViewModel { Message = "Event Added Successfully", IsSaved = true }; } else { TempData["Message"] = new MessageViewModel { Message = "Something Went wrong", IsError = true }; } if (Request.Form["save"] != null) return RedirectToAction("EventIndex"); return RedirectToAction("AddEvent"); }