Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        public ActionResult Create(programevent programevent)
        {
            int      ministryID = GoalRepository.GetGoalByID(programevent.goalID).ministryID;
            constant cont       = ConstantRepository.GetConstantListByCategory("Ministry Activity").FirstOrDefault(e => e.ConstantName == "Program/Event");

            try
            {
                //set meeting on calendar
                calendar cal = new calendar();
                cal.ministryID   = ministryID;
                cal.EventType    = cont.constantID;
                cal.CalendarDate = programevent.C_When;
                cal.StartTime    = programevent.BeginTime;
                cal.EndTime      = programevent.EndTime;
                cal.Location     = programevent.C_Where;
                cal.Title        = programevent.Title;
                cal.Conductor    = MemberRepository.GetMemberByID(programevent.C_Who).FullNameTitle;
                cal.PublicAccess = true;
                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);
                programevent.CalendarID = cal.calendarID;

                if (ModelState.IsValid)
                {
                    db.programevents.Add(programevent);
                    db.SaveChanges();
                    ProgramEventRepository.AddRecord(programevent);
                    TempData["Message2"] = "Event added successfully.";
                    GetData(ministryID);
                    return(RedirectToAction("Create", new { GoalID = programevent.goalID }));
                }
            }
            catch (Exception ex)
            {
                TempData["Message2"] = "Error adding event";
            }
            GetData(ministryID);
            return(PartialView(programevent));
        }