public ActionResult CreateEvent(EventDL Event) { var ClubNames = context.Clubs.Select(l => l.ClubName).ToList(); ViewBag.Clubs = ClubNames; DateTime today = DateTime.Parse(DateTime.Today.ToString("yyyy-MM-dd H:mm:ss")); if (ModelState.IsValid) { if (Event.StartDate > Event.EndDate) { ViewBag.errMsg = "Start Date Should Be Less Than End Date"; return(View()); } if (Event.StartDate < today) { ViewBag.errMsg = "Start Date can not Be Less Than Current Date"; return(View()); } Event.LikeCount = 0; Event.DisLikeCount = 0; context.Events.Add(Event); context.SaveChanges(); return(RedirectToAction("Event")); } return(View()); }
public EventBL() { _eventDL = new EventDL(); }