Пример #1
0
        public ActionResult EditAttendee(int ID)
        {
            DSRCManagementSystemEntities1 db = new DSRCManagementSystemEntities1();

            DSRCManagementSystem.Models.MeetingSchedule editobj = new DSRCManagementSystem.Models.MeetingSchedule();
            editobj.Id = ID;

            var ProjectLead = (from t in db.Users.Where(x => x.IsActive == true)
                               join atn in db.MeetingGuids on t.UserID equals atn.UserId

                               select new
            {
                Id = t.UserID,
                FirstName = t.FirstName + " " + (t.LastName.Length > 0 ? t.LastName : "")
            }).ToList();

            var AttendeeList = (from a in db.MettingSchedules
                                where a.Id == ID
                                select new MeetingSchedule()
            {
                Attendees = a.Attendees
            }).FirstOrDefault();

            List <int> selectedAttendees = new List <int>();

            if (AttendeeList.Attendees != null)
            {
                string[] tokens = AttendeeList.Attendees.Split(new string[] { "," }, StringSplitOptions.None);
                foreach (var i in tokens)
                {
                    int val;
                    int.TryParse(i, out val);
                    selectedAttendees.Add(val);
                }
            }

            ViewBag.Leaders = new MultiSelectList(ProjectLead, "Id", "FirstName", selectedAttendees);

            return(View(editobj));
        }
Пример #2
0
        public ActionResult MeetingSchedule()
        {
            DSRCManagementSystemEntities1 db = new DSRCManagementSystemEntities1();
            int userId     = Convert.ToInt32(Session["UserID"]);
            var getBracnch = db.Users.Where(o => o.UserID == userId).Select(x => x.BranchId).FirstOrDefault();

            var date = DateTime.Now;

            DateTime beginningOfMonth = new DateTime(date.Year, date.Month, 1);

            while (date.Date.AddDays(1).DayOfWeek != CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek)
            {
                date = date.AddDays(1);
            }

            var result = (int)Math.Truncate((double)date.Subtract(beginningOfMonth).TotalDays / 7f) + 1;

            ViewBag.Week = new SelectList(new[] { new { Text = "--Select--", Value = 0 }, new { Text = "1", Value = 1 }, new { Text = "2", Value = 2 } }, "Value", "Text", 0);


            DSRCManagementSystem.Models.MeetingSchedule objmeeting = new DSRCManagementSystem.Models.MeetingSchedule();



            var firstdateofweek = DateTime.Now;
            var cal             = System.Globalization.DateTimeFormatInfo.CurrentInfo.Calendar;
            Dictionary <string, DateTime> currentWeek = new Dictionary <string, DateTime>();
            Dictionary <string, DateTime> nextWeek    = new Dictionary <string, DateTime>();

            var weekofYear = cal.GetWeekOfYear(DateTime.Now, System.Globalization.CalendarWeekRule.FirstDay, System.DayOfWeek.Monday);

            firstdateofweek = FirstDateOfWeek(DateTime.Now.Year, weekofYear, CultureInfo.CurrentCulture);
            int i = 0;

            while (i != 12) // skiped weeekend days...
            {
                if (i < 5)
                {
                    currentWeek.Add(firstdateofweek.AddDays(i).DayOfWeek.ToString(), firstdateofweek.AddDays(i).Date);
                }
                else if (i >= 7)
                {
                    nextWeek.Add(firstdateofweek.AddDays(i).DayOfWeek.ToString(), firstdateofweek.AddDays(i).Date);
                }

                i++;
            }

            if (result % 2 == 0)
            {
                List <DSRCManagementSystem.Models.MeetingSchedule> objmail = new List <DSRCManagementSystem.Models.MeetingSchedule>();

                if (getBracnch != 1)
                {
                    objmail = (from metting_schedule in db.MettingSchedules
                               join proj in db.Projects on metting_schedule.ProjectID equals proj.ProjectID

                               join days in db.Master_Days on metting_schedule.Day equals days.Days
                               where proj.ProjectID == 0
                               select new DSRCManagementSystem.Models.MeetingSchedule
                    {
                        Id = metting_schedule.Id,
                        Project = proj.ProjectName,
                        ProjectID = metting_schedule.ProjectID,
                        Day = metting_schedule.Day,
                        DayId = days.Id,
                        Week = metting_schedule.Week ?? 0,
                        Attendees = metting_schedule.Attendees,

                        From = metting_schedule.TimeSlot,
                        To = metting_schedule.EndTime,
                    }).OrderByDescending(x => x.Week).ThenBy(x => x.DayId).ThenBy(x => x.From).ToList();


                    foreach (var meetingSchedule in objmail)
                    {
                        meetingSchedule.Attendees = MeetingScheduleController.GetUserString(db, meetingSchedule.Attendees);
                        if (result % 2 == meetingSchedule.Week / 2)
                        {
                            meetingSchedule.Date = nextWeek[meetingSchedule.Day].ToString("dd/MM/yyyy");
                        }
                        else
                        {
                            meetingSchedule.Date = currentWeek[meetingSchedule.Day].ToString("dd/MM/yyyy");
                        }
                    }
                }
                else
                {
                    objmail = (from metting_schedule in db.MettingSchedules
                               join proj in db.Projects on metting_schedule.ProjectID equals proj.ProjectID

                               join days in db.Master_Days on metting_schedule.Day equals days.Days
                               select new DSRCManagementSystem.Models.MeetingSchedule
                    {
                        Id = metting_schedule.Id,
                        Project = proj.ProjectName,
                        ProjectID = metting_schedule.ProjectID,
                        Day = metting_schedule.Day,
                        DayId = days.Id,
                        Week = metting_schedule.Week ?? 0,
                        Attendees = metting_schedule.Attendees,

                        From = metting_schedule.TimeSlot,
                        To = metting_schedule.EndTime,
                    }).OrderByDescending(x => x.Week).ThenBy(x => x.DayId).ThenBy(x => x.From).ToList();


                    foreach (var meetingSchedule in objmail)
                    {
                        meetingSchedule.Attendees = MeetingScheduleController.GetUserString(db, meetingSchedule.Attendees);
                        if (result % 2 == meetingSchedule.Week / 2)
                        {
                            meetingSchedule.Date = nextWeek[meetingSchedule.Day].ToString("dd/MM/yyyy");
                        }
                        else
                        {
                            meetingSchedule.Date = currentWeek[meetingSchedule.Day].ToString("dd/MM/yyyy");
                        }
                    }
                }
                return(View(objmail));
            }
            else
            {
                List <DSRCManagementSystem.Models.MeetingSchedule> objmail = new List <DSRCManagementSystem.Models.MeetingSchedule>();

                if (getBracnch != 1)
                {
                    objmail = (from metting_schedule in db.MettingSchedules
                               join proj in db.Projects on metting_schedule.ProjectID equals proj.ProjectID

                               join days in db.Master_Days on metting_schedule.Day equals days.Days
                               where proj.ProjectID == 0
                               select new DSRCManagementSystem.Models.MeetingSchedule
                    {
                        Id = metting_schedule.Id,
                        Project = proj.ProjectName,
                        ProjectID = metting_schedule.ProjectID,
                        Day = metting_schedule.Day,
                        DayId = days.Id,
                        Week = metting_schedule.Week ?? 0,
                        Attendees = metting_schedule.Attendees,

                        From = metting_schedule.TimeSlot,
                        To = metting_schedule.EndTime,
                    }).OrderByDescending(x => x.Week).ThenBy(x => x.DayId).ThenBy(x => x.From).ToList();


                    foreach (var meetingSchedule in objmail)
                    {
                        meetingSchedule.Attendees = MeetingScheduleController.GetUserString(db, meetingSchedule.Attendees);
                        if (result % 2 == meetingSchedule.Week / 2)
                        {
                            meetingSchedule.Date = nextWeek[meetingSchedule.Day].ToString("dd/MM/yyyy");
                        }
                        else
                        {
                            meetingSchedule.Date = currentWeek[meetingSchedule.Day].ToString("dd/MM/yyyy");
                        }
                    }
                }
                else
                {
                    objmail = (from metting_schedule in db.MettingSchedules
                               join proj in db.Projects on metting_schedule.ProjectID equals proj.ProjectID

                               join days in db.Master_Days on metting_schedule.Day equals days.Days
                               select new DSRCManagementSystem.Models.MeetingSchedule
                    {
                        Id = metting_schedule.Id,
                        Project = proj.ProjectName,
                        ProjectID = metting_schedule.ProjectID,
                        Day = metting_schedule.Day,
                        DayId = days.Id,
                        Week = metting_schedule.Week ?? 0,
                        Attendees = metting_schedule.Attendees,

                        From = metting_schedule.TimeSlot,
                        To = metting_schedule.EndTime,
                    }).OrderBy(x => x.Week).ThenBy(x => x.DayId).ThenBy(x => x.From).ToList();

                    foreach (var meetingSchedule in objmail)
                    {
                        meetingSchedule.Attendees = MeetingScheduleController.GetUserString(db, meetingSchedule.Attendees);

                        if (result % 2 == meetingSchedule.Week / 2)
                        {
                            meetingSchedule.Date = nextWeek[meetingSchedule.Day].ToString("dd/MM/yyyy");
                        }
                        else
                        {
                            meetingSchedule.Date = currentWeek[meetingSchedule.Day].ToString("dd/MM/yyyy");
                        }
                    }
                }

                return(View(objmail));
            }
        }