示例#1
0
        public ActionResult Index(SurveyListViewModel model)
        {
            Session["CurrentPage"] = "SurveyIndex";
            model.UserId           = loggedInUserId;

            if (model != null && model.UserId > 0)
            {
                string[] pageConditions = { };
                if (HttpContext.Session["SurveyPagingCriteria"] != null)
                {
                    pageConditions = HttpContext.Session["SurveyPagingCriteria"].ToString().Split('|');
                    model.SortPageOptions.SortField   = pageConditions[(int)PageConditions.SortColumn].ToString();
                    model.SortPageOptions.SortOrder   = pageConditions[(int)PageConditions.SortOrder].ToString();
                    model.SortPageOptions.PageSize    = Convert.ToInt16(pageConditions[(int)PageConditions.PageSize]);
                    model.SortPageOptions.CurrentPage = Convert.ToInt16(pageConditions[(int)PageConditions.CurrentPage]);
                }
                else
                {
                    model.SortPageOptions.CurrentPage = 1;
                    model.SortPageOptions.PageSize    = LAMPConstants.LAMP_PAGE_SIZE;
                    model.SortPageOptions.SortField   = "SurveyName";
                    model.SortPageOptions.SortOrder   = "asc";
                }
            }
            SurveyListViewModel response = new SurveyListViewModel();

            response = _userService.GetSurveys(model);
            GetResponse(model, ref response);

            ModelState.Clear();
            return(View(response));
        }
示例#2
0
        /// <summary>
        /// To delete a survey.
        /// </summary>
        /// <param name="SurveyId">SurveyId</param>
        /// <returns></returns>
        public ActionResult DeleteSurvey(long SurveyId)
        {
            SurveyListViewModel response = new SurveyListViewModel();

            response = _userService.DeleteSurvey(SurveyId, loggedInUserId);
            return(PartialView("_SurveyListPartial", response));
        }
        public async Task <IActionResult> List(SurveyListViewModel model)
        {
            var userId = GetUserId();

            model.Surveys = await service.GetBy(userId, model.BeginDate, model.EndDate);

            return(View(model));
        }
示例#4
0
 public SurveyList()
 {
     InitializeComponent();
     ViewModel      = new SurveyListViewModel();
     BindingContext = ViewModel;
     WebAPI api  = new WebAPI();
     string list = api.Get("survey/getlist"); //lijst van mogelijke surveys ophalen
     int    a    = 0;
 }
        public ViewViewComponentResult Invoke()
        {
            var model = new SurveyListViewModel()
            {
                Surveys       = _surveyService.GetAll(),
                CurrentSurvey = Convert.ToInt32(HttpContext.Request.Query["surveyId"])
            };

            return(View(model));
        }
示例#6
0
        public ViewResult List()
        {
            ViewBag.Title = "Опросы";

            SurveyListViewModel obj = new SurveyListViewModel();

            obj.allsurvey  = _survey.AllSurveys;
            obj.currSurvey = "Мои опросы";

            return(View(obj));
        }
示例#7
0
        public async Task <IActionResult> Index()
        {
            var currentUser = await _userManager.GetUserAsync(User);

            if (currentUser == null)
            {
                return(Challenge());
            }
            var surveys = await _surveyService.GetAllSurveysAsync(currentUser);

            var model = new SurveyListViewModel()
            {
                Surveys = surveys
            };

            return(View(model));
        }
示例#8
0
        // GET: Survey
        public ActionResult Index(string search, int?page, int?items)
        {
            SurveyListViewModel model = new SurveyListViewModel();

            model.PageInfo = new PageInfo()
            {
                PageTitle       = "Surveys",
                PageDescription = "List of Survays."
            };

            model.searchTerm = search;
            model.pageNo     = page ?? 1;
            model.pageSize   = items ?? 10;

            if (string.IsNullOrEmpty(model.searchTerm))
            {
                model.Surveys = db.Surveys
                                .Where(q => q.IsActive)
                                .OrderByDescending(x => x.ModifiedOn)
                                .Skip((model.pageNo - 1) * model.pageSize)
                                .Take(model.pageSize)
                                .ToList();

                model.TotalCount = db.Surveys.Where(q => q.IsActive).Count();
            }
            else
            {
                model.Surveys = db.Surveys
                                .Where(q => q.IsActive)
                                .Where(x => x.Name.ToLower().StartsWith(model.searchTerm))
                                .OrderByDescending(x => x.ModifiedOn)
                                .Skip((model.pageNo - 1) * model.pageSize)
                                .Take(model.pageSize)
                                .ToList();

                model.TotalCount = db.Surveys
                                   .Where(q => q.IsActive)
                                   .Where(x => x.Name.ToLower().StartsWith(model.searchTerm))
                                   .Count();
            }

            model.Pager = new Pager(model.TotalCount, model.pageNo, model.pageSize);

            return(View(model));
        }
示例#9
0
        public ActionResult SearchSurveys(SurveyListViewModel model, string command, string searchString, string sortColumn, string sortOrder, int?pageSize, int?page)
        {
            var response = new SurveyListViewModel();

            model.UserId = loggedInUserId;

            if (model.SortPageOptions != null && model.SortPageOptions.PageSize == 0 && pageSize > 0)
            {
                model.SortPageOptions.CurrentPage = (short)page;
                model.SortPageOptions.PageSize    = (short)pageSize;
                model.SortPageOptions.SortField   = sortColumn;
                model.SortPageOptions.SortOrder   = sortOrder;
            }
            else if (model.SortPageOptions != null && model.SortPageOptions.PageSize > 0)
            {
                model.SortPageOptions.CurrentPage = model.SortPageOptions.CurrentPage;
                model.SortPageOptions.PageSize    = model.SortPageOptions.PageSize;
                model.SortPageOptions.SortField   = model.SortPageOptions.SortField;
                model.SortPageOptions.SortOrder   = model.SortPageOptions.SortOrder;
            }

            if (command == "Search")
            {
                model.SortPageOptions.CurrentPage = 1;
                model.SortPageOptions.PageSize    = LAMPConstants.LAMP_PAGE_SIZE;
                model.SortPageOptions.SortField   = "SurveyName";
                model.SortPageOptions.SortOrder   = "asc";
            }

            if (searchString != null && searchString.Trim().Length > 0)
            {
                model.SearchText = searchString;
            }

            response = _userService.GetSurveys(model);
            GetResponse(model, ref response);
            response.SearchText = searchString;
            ModelState.Clear();
            return(PartialView("_SurveyListPartial", response));
        }
示例#10
0
        /// <summary>
        /// To set paging  and sort page options to the list.
        /// </summary>
        /// <param name="model"></param>
        /// <param name="response"></param>
        private void GetResponse(SurveyListViewModel model, ref SurveyListViewModel response)
        {
            response.SearchText = ((model.SearchText == null || model.SearchText.Length == 0) ? "" : model.SearchText);
            var _SortPageOptions = new SortPageOptions();

            if (model.SortPageOptions == null)
            {
                _SortPageOptions.SortField   = "SurveyName";
                _SortPageOptions.SortOrder   = "asc";
                _SortPageOptions.CurrentPage = 1;
                _SortPageOptions.PageSize    = LAMPConstants.LAMP_PAGE_SIZE;
            }
            else
            {
                _SortPageOptions.SortField   = ((model.SortPageOptions.SortField == null || model.SortPageOptions.SortField.Length == 0) ? "SurveyName" : model.SortPageOptions.SortField);
                _SortPageOptions.SortOrder   = (model.SortPageOptions.SortOrder == null || model.SortPageOptions.SortOrder.Length == 0) ? "asc" : model.SortPageOptions.SortOrder; // sortOrder;
                _SortPageOptions.CurrentPage = model.SortPageOptions.CurrentPage == 0 ? Convert.ToInt16(1) : model.SortPageOptions.CurrentPage;                                    // page;
                _SortPageOptions.PageSize    = model.SortPageOptions.PageSize == 0 ? Convert.ToInt16(10) : model.SortPageOptions.PageSize;
            }
            response.SortPageOptions = _SortPageOptions;

            var providerUsers = response.SurveyList.ToPagedList <SurveyForList>((int)response.SortPageOptions.CurrentPage, (int)response.SortPageOptions.PageSize);

            response.PagedSurveyList = new StaticPagedList <SurveyForList>(providerUsers, (int)response.SortPageOptions.CurrentPage, (int)response.SortPageOptions.PageSize, response.SurveyList.Count);
            response.SurveyList      = response.SurveyList.Skip((_SortPageOptions.CurrentPage - 1) * _SortPageOptions.PageSize).ToList();
            response.SurveyList      = response.SurveyList.Take(_SortPageOptions.PageSize).ToList();
            response.SurveyList.Select(survey =>
            {
                survey.CreatedOnString = Helper.GetDateString(survey.CreatedOn, "MM/dd/yyyy");

                return(survey);
            }).ToList();

            // Session variable is used to handle paging while back to users page like edit use, view user.
            HttpContext.Session["SurveyPagingCriteria"] = response.SortPageOptions.SortField + "|" + response.SortPageOptions.SortOrder + "|" + response.SortPageOptions.PageSize.ToString() + "|" + response.SortPageOptions.CurrentPage.ToString();
        }
示例#11
0
 public SurveyManage()
 {
     InitializeComponent();
     BindingContext = new SurveyListViewModel();
 }