Exemple #1
0
        public ActionResult TakeOptions(long Id, PollTakeOptionsFormModel model)
        {
            Poll item = GetSession.Get <Poll>(Id);

            if (item != null)
            {
                if (ModelState.IsValid)
                {
                    CurrentPollId = Id;

                    if (model.LCID > 0)
                    {
                        Poll poll = GetSession.QueryOver <Poll>()
                                    .Where(x => x.Object != null && x.Object.Id == Id && x.LCID == model.LCID)
                                    .SingleOrDefault();

                        if (poll != null)
                        {
                            CurrentPollId = poll.Id;
                        }
                    }

                    CurrentPollDepartmentId = model.Department_id;
                    CurrentPollManagerId    = model.Manager_id;
                    CurrentPollLCID         = model.LCID;
                }

                return(RedirectToAction("TakeIntro", new { Id = CurrentPollId }));
            }
            else
            {
                return(RedirectToAction("Take", new { Id = Id }));
            }
        }
        public ActionResult TakeOptions(long Id, PollTakeOptionsFormModel model)
        {
            Poll item = GetSession.Get<Poll>(Id);

            if (item != null)
            {
                if (ModelState.IsValid)
                {
                    CurrentPollId = Id; 
                    
                    if (model.LCID > 0)
                    {
                        Poll poll = GetSession.QueryOver<Poll>()
                            .Where(x => x.Object != null && x.Object.Id == Id && x.LCID == model.LCID)
                            .SingleOrDefault();

                        if (poll != null)
                        {
                            CurrentPollId = poll.Id;
                        }
                    }

                    CurrentPollDepartmentId = model.Department_id;
                    CurrentPollManagerId = model.Manager_id;
                    CurrentPollLCID = model.LCID;
                }

                return RedirectToAction("TakeIntro", new { Id = CurrentPollId });
            }
            else
            {
                return RedirectToAction("Take", new { Id = Id });
            }
        }
        public ActionResult TakeOptions(long id)
        {
            Poll item = GetSession.Get<Poll>(id);

            if (item != null)
            {
                if (item.AnonymousUser != null && item.AnonymousUser.Id == EmployeesHelper.GetCurrentEmployee().Id)
                {
                    PollTakeOptionsFormModel model = new PollTakeOptionsFormModel()
                    {
                        Poll = item,
                        IsRightToLeft = CurrentPollLCID.HasValue ? CultureHelper.IsRightToLeft(CurrentPollLCID.Value) : true
                    };

                    // Cultures
                    model.Cultures = new List<SelectListItem>();
                    IList<Poll> objects = GetSession.QueryOver<Poll>()
                        .Where(x => x.Id == id || (x.Object != null && x.Object.Id == id))
                        .List();
                    foreach (Poll pollObject in objects)
                    {
                        model.Cultures.Add(new SelectListItem()
                        {
                            Value = pollObject.LCID.ToString(),
                            Text = CultureHelper.GetNativeName(pollObject.LCID)
                        });
                    }

                    // Departments
                    model.Departments = new List<SelectListItem>();
                    IList<Department> departments = GetSession.QueryOver<Department>().List();
                    foreach (Department department in departments)
                    {
                        model.Departments.Add(new SelectListItem()
                        {
                            Value = department.Id.ToString(),
                            Text = department.Name
                        });
                    }

                    // Managers
                    model.Managers = new List<SelectListItem>();
                    IList<Employee> managers = GetSession.QueryOver<Employee>()
                        .Where(x => x.Manager == null)
                        .List();
                    foreach (Employee manager in managers)
                    {
                        model.Managers.Add(new SelectListItem()
                        {
                            Value = manager.Id.ToString(),
                            Text = manager.FullName
                        });
                    }

                    return View("TakeOptions", model);
                }
                else
                {
                    CurrentPollId = item.Id;
                    if (EmployeesHelper.GetCurrentEmployee().Department != null)
                    {
                        CurrentPollDepartmentId = EmployeesHelper.GetCurrentEmployee().Department.Id;
                    }
                    if (EmployeesHelper.GetCurrentEmployee().Manager != null)
                    {
                        CurrentPollManagerId = EmployeesHelper.GetCurrentEmployee().Manager.Id;
                    }
                    if (item.LCID > 0)
                    {
                        CurrentPollLCID = item.LCID;
                    }

                    return RedirectToAction("TakeIntro", new { Id = CurrentPollId });
                }
            }
            else
            {
                return RedirectToAction("Take", new { Id = id });
            }
        }
Exemple #4
0
        public ActionResult TakeOptions(long id)
        {
            Poll item = GetSession.Get <Poll>(id);

            if (item != null)
            {
                if (item.AnonymousUser != null && item.AnonymousUser.Id == EmployeesHelper.GetCurrentEmployee().Id)
                {
                    PollTakeOptionsFormModel model = new PollTakeOptionsFormModel()
                    {
                        Poll          = item,
                        IsRightToLeft = CurrentPollLCID.HasValue ? CultureHelper.IsRightToLeft(CurrentPollLCID.Value) : true
                    };

                    // Cultures
                    model.Cultures = new List <SelectListItem>();
                    IList <Poll> objects = GetSession.QueryOver <Poll>()
                                           .Where(x => x.Id == id || (x.Object != null && x.Object.Id == id))
                                           .List();
                    foreach (Poll pollObject in objects)
                    {
                        model.Cultures.Add(new SelectListItem()
                        {
                            Value = pollObject.LCID.ToString(),
                            Text  = CultureHelper.GetNativeName(pollObject.LCID)
                        });
                    }

                    // Departments
                    model.Departments = new List <SelectListItem>();
                    IList <Department> departments = GetSession.QueryOver <Department>().List();
                    foreach (Department department in departments)
                    {
                        model.Departments.Add(new SelectListItem()
                        {
                            Value = department.Id.ToString(),
                            Text  = department.Name
                        });
                    }

                    // Managers
                    model.Managers = new List <SelectListItem>();
                    IList <Employee> managers = GetSession.QueryOver <Employee>()
                                                .Where(x => x.Manager == null)
                                                .List();
                    foreach (Employee manager in managers)
                    {
                        model.Managers.Add(new SelectListItem()
                        {
                            Value = manager.Id.ToString(),
                            Text  = manager.FullName
                        });
                    }

                    return(View("TakeOptions", model));
                }
                else
                {
                    CurrentPollId = item.Id;
                    if (EmployeesHelper.GetCurrentEmployee().Department != null)
                    {
                        CurrentPollDepartmentId = EmployeesHelper.GetCurrentEmployee().Department.Id;
                    }
                    if (EmployeesHelper.GetCurrentEmployee().Manager != null)
                    {
                        CurrentPollManagerId = EmployeesHelper.GetCurrentEmployee().Manager.Id;
                    }
                    if (item.LCID > 0)
                    {
                        CurrentPollLCID = item.LCID;
                    }

                    return(RedirectToAction("TakeIntro", new { Id = CurrentPollId }));
                }
            }
            else
            {
                return(RedirectToAction("Take", new { Id = id }));
            }
        }