public ActionResult Create(meeting meeting, string CallerType = "") { meeting mtg = db.meetings.FirstOrDefault(e => e.meetingID == meeting.meetingID && e.Title == meeting.Title); if (mtg != null) { TempData["Message2"] = "Meeting already exist"; return(PartialView(meeting)); } try { //if (budget.Comment == null) { budget.Comment = ""; } constant cont = ConstantRepository.GetConstantListByCategory("Ministry Activity").FirstOrDefault(e => e.ConstantName == "Ministry Meeting"); //set meeting on calendar calendar cal = new calendar(); cal.ministryID = meeting.ministryID; cal.EventType = cont.constantID; cal.CalendarDate = meeting.meetingDate; cal.StartTime = meeting.StartTime; cal.EndTime = meeting.EndTime; cal.Location = meeting.meetingVenue; cal.Title = meeting.Title; cal.Conductor = meeting.Conductor; cal.PublicAccess = false; cal.Description = ""; cal.EnteredBy = User.Identity.Name.ToString(); cal.DateEntered = System.DateTime.Today; cal.Status = "Active"; db.calendars.Add(cal); db.SaveChanges(); CalendarRepository.AddRecord(cal); meeting.CalendarID = cal.calendarID; if (ModelState.IsValid) { db.meetings.Add(meeting); db.SaveChanges(); MeetingRepository.AddRecord(meeting); TempData["Message2"] = "Meeting created successfully."; GetData(meeting.ministryID); if (CallerType == "Ministry") { return(RedirectToAction("Create", new { MinistryID = meeting.ministryID, CallerType = "Ministry" })); } else { return(RedirectToAction("Create")); } } } catch (Exception ex) { TempData["Message2"] = "Error adding meeting record"; } GetData(meeting.ministryID); return(PartialView(meeting)); }