public ActionResult GetChefs(bool?any)
        {
            var items = repo.GetAll <Chef>().ToArray()
                        .Select(o => new KeyContent(o.Id, string.Format("{0} {1}", o.FirstName, o.LastName))).ToList();

            if (any.HasValue)
            {
                items.Insert(0, new KeyContent("", Mui.any));
            }

            return(Json(items));
        }
Beispiel #2
0
        public ActionResult Search(int[] selected)
        {
            var r = repo.GetAll <Role>();

            if (selected != null)
            {
                r = r.Where(o => !selected.Contains(o.Id));
            }

            return(Json(new AjaxListResult
            {
                Items = r.ToArray().Select(o => new KeyContent(o.Id, o.Name))
            }));
        }
Beispiel #3
0
        public ActionResult GetChefs(bool?any)
        {
            var items = new List <KeyContent>();

            if (any.HasValue)
            {
                items.Insert(0, new KeyContent(string.Empty, Mui.any));
            }

            Func <List <KeyContent> > getData = () =>
            {
                return(repo.GetAll <Chef>(WebUtils.IsUserAdmin()).ToArray()
                       .Select(o => new KeyContent(o.Id, $"{o.FirstName} {o.LastName}")).ToList());
            };

            var res = !WebUtils.IsUserAdmin() ? cache.Get("chefs1", () => getData(), typeof(Chef)) : getData();

            items.AddRange(res);

            return(Json(items));
        }
Beispiel #4
0
        public IPageable <FieldsetDisplay> GetDisplayPageable(int page, int pageSize)
        {
            var pageable = u.GetPageable <Fieldset>(page, pageSize);
            var states   = u.GetAll <FieldsetState>();
            var displays = new Pageable <FieldsetDisplay>();

            displays.InjectFrom(pageable);
            displays.Page = pageable.Page.Join(states, fs => fs.StateId, s => s.Id, (fs, s) =>
                                               new FieldsetDisplay
            {
                Id    = fs.Id,
                Year  = fs.Year,
                Name  = fs.Name,
                State = s.Name
            }).ToArray();

            return(displays);
        }
Beispiel #5
0
        public ActionResult Search(string search, int?pivot)
        {
            var pageSize = 7;
            var list     = repo.GetAll <Feedback>().OrderByDescending(o => o.Id);

            var items  = (pivot.HasValue ? list.Where(o => o.Id <= pivot.Value) : list).Take(pageSize + 1).ToList();
            var isMore = items.Count > pageSize;

            var result = new AjaxListResult
            {
                Content = this.RenderPartialView("ListItems/Feedback", items.Take(pageSize).ToList()),
                More    = isMore
            };

            if (isMore)
            {
                result.Pivot = items.Last().Id;
            }

            return(Json(result));
        }