Example #1
0
        public void Requiredneeds(bool type)
        {
            var      setting = _SettingService.GetOptionsForEdit();
            DateTime start = DateTime.Now, end = DateTime.Now, now = DateTime.Now;
            bool     state = false;

            if (type == true &&
                !string.IsNullOrEmpty(setting.Start_Election_Date) && !string.IsNullOrEmpty(setting.Start_Election_Time) &&
                !string.IsNullOrEmpty(setting.End_Election_Date) && !string.IsNullOrEmpty(setting.End_Election_Time))
            {
                start = DateTime.ParseExact(setting.Start_Election_Date + " " + setting.Start_Election_Time,
                                            "MM/dd/yyyy hh:mm tt", CultureInfo.InvariantCulture); //.TimeOfDay;
                end = DateTime.ParseExact(setting.End_Election_Date + " " + setting.End_Election_Time,
                                          "MM/dd/yyyy hh:mm tt", CultureInfo.InvariantCulture);   //.TimeOfDay;
            }
            else if (type == false &&
                     !string.IsNullOrEmpty(setting.Start_Remove_Date) && !string.IsNullOrEmpty(setting.Start_Remove_Time) &&
                     !string.IsNullOrEmpty(setting.End_Remove_Date) && !string.IsNullOrEmpty(setting.End_Remove_Time))
            {
                start = DateTime.ParseExact(setting.Start_Remove_Date + " " + setting.Start_Remove_Time,
                                            "MM/dd/yyyy hh:mm tt", CultureInfo.InvariantCulture); //.TimeOfDay;
                end = DateTime.ParseExact(setting.End_Remove_Date + " " + setting.End_Remove_Time,
                                          "MM/dd/yyyy hh:mm tt", CultureInfo.InvariantCulture);   //.TimeOfDay;
            }
            ////(now >= start)  --> true
            ////(now <= end)  --> false
            if ((start < now) && (now < end))
            // (DateTime.Compare(start, now) == 0 && DateTime.Compare(end, now) == 0)
            {
                state = true;

                var term = setting.Term;//_SettingService.GetOptionsForEdit().Term;
                if (term != null)
                {
                    ViewBag.TermName = term.Name;
                    var plist = _PeresentedCoursesService.GetByTermName(term.Name);
                    if (plist != null)
                    {
                        ViewBag.prlist = plist;
                    }
                    else
                    {
                        IEnumerable <PeresentedCourses> pp = new List <PeresentedCourses>();
                        ViewBag.prlist = pp;
                    }
                }
                string userName = HttpContext.User.Identity.Name;
                var    stu      = _StudentService.GetByUserId(_UserService.GetUserByUserName(userName).Id);
                if (stu != null)
                {
                    ViewBag.fname = stu.FirstName;
                    ViewBag.lname = stu.LastName;
                    ViewBag.sno   = stu.SNO;
                    var userselectedlist = _ElectionService.GetByStudent(stu.Id);
                    if (userselectedlist != null)
                    {
                        ViewBag.usersellist = userselectedlist;
                    }
                    else
                    {
                        IEnumerable <ElectionViewModel> ss = new List <ElectionViewModel>();
                        ViewBag.usersellist = ss;
                    }
                }
            }
            //if (DateTime.Compare(start, now) > 0/* && DateTime.Compare(end, now) < 0*/)
            //    state = true;
            //TimeSpan ts = now - start;

            //ViewBag.now = now;
            //ViewBag.start = start;
            //ViewBag.end = end;
            //ViewBag.state = state;
        }