Exemple #1
0
        public ShiftInfoModel GetShiftInfo(ShiftSearchModel searchModel)
        {
            ShiftInfoModel     info    = new ShiftInfoModel();
            DataContext        dc      = new DataContext(this.DbString);
            IShiftRepository   rep     = new ShiftRepository(dc);
            IQueryable <Shift> results = rep.Search(searchModel);

            info.shiftCount = dc.Context.GetTable <Shift>().Where(c => c.id.Equals(results.Count() > 0 ? results.First().id : -1)).Count();

            return(info);
        }
Exemple #2
0
        /// <summary>
        /// Prepare shift search model
        /// </summary>
        /// <param name="searchModel">Shift search model</param>
        /// <returns>Shift search model</returns>
        public virtual ShiftSearchModel PrepareShiftSearchModel(ShiftSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }
            //prepare page parameters
            searchModel.SetGridPageSize();

            return(searchModel);
        }
Exemple #3
0
        public virtual IActionResult List(ShiftSearchModel searchModel)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageShifts))
            {
                return(AccessDeniedKendoGridJson());
            }

            //prepare model
            var model = _shiftModelFactory.PrepareShiftListModel(searchModel);

            return(Json(model));
        }
Exemple #4
0
        public ActionResult GetShifts(ShiftSearchModel shiftSearchModel)
        {
            var shifts = ShiftManager.GetShifts(shiftSearchModel);

            if (shifts.Count != 0)
            {
                return(PartialView(shifts));
            }
            else
            {
                return(RedirectToAction("ShiftError", "Error"));
            }
        }
Exemple #5
0
        public ActionResult Search([Bind(Include = "Name")]  ShiftSearchModel q)
        {
            int pageIndex = 0;

            int.TryParse(Request.QueryString.Get("page"), out pageIndex);
            pageIndex = PagingHelper.GetPageIndex(pageIndex);

            IShiftService ss = new ShiftService(Settings.Default.db);

            IPagedList <Shift> models = ss.Search(q).ToPagedList(pageIndex, Settings.Default.pageSize);

            ViewBag.Query = q;

            return(View("Index", models));
        }
Exemple #6
0
        /// <summary>
        /// Prepare paged shift list model
        /// </summary>
        /// <param name="searchModel">Shift search model</param>
        /// <returns>Shift list model</returns>
        public virtual ShiftListModel PrepareShiftListModel(ShiftSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            var entities = _shiftService.GetAll(name: searchModel.SearchName, pageIndex: searchModel.Page - 1, pageSize: searchModel.PageSize, showHidden: true);

            var model = new ShiftListModel
            {
                Data  = entities.PaginationByRequestModel(searchModel).Select(s => s.ToModel <ShiftModel>()),
                Total = entities.TotalCount
            };

            return(model);
        }
Exemple #7
0
        public ActionResult Index(int?page)
        {
            int pageIndex = PagingHelper.GetPageIndex(page);

            ShiftSearchModel q = new ShiftSearchModel();

            IShiftService ss = new ShiftService(Settings.Default.db);

            IPagedList <Shift> models = ss.Search(q).ToPagedList(pageIndex, Settings.Default.pageSize);

            ViewBag.Query = q;

            ShiftInfoModel info = ss.GetShiftInfo(q);

            ViewBag.Info = info;

            return(View(models));
        }
Exemple #8
0
        /// <summary>
        /// Возвращает список смен, попараметрам поиска
        /// </summary>
        /// <param name="shiftSearchModel">Модель поиска смены</param>
        /// <returns></returns>
        public List <Shift> GetShifts(ShiftSearchModel shiftSearchModel)
        {
            List <Shift> shifts  = new List <Shift>();
            DateTime     defTime = new DateTime();

            var query = ShiftRepo.GetList().AsQueryable();

            if (shiftSearchModel.FactoryId != 0)
            {
                query = query.Where(c => c.FactoryId == shiftSearchModel.FactoryId);
            }

            if (shiftSearchModel.Date != defTime)
            {
                query = query.Where(c => c.Date == shiftSearchModel.Date);
            }
            if (shiftSearchModel.Number != 0)
            {
                query = query.Where(c => c.Number == shiftSearchModel.Number);
            }
            if (shiftSearchModel.UserId != "0")
            {
                query = query.Where(c => c.UserId == shiftSearchModel.UserId);
            }

            shifts = query.ToList();


            if (shifts.Count != 0)
            {
                foreach (var sh in shifts)
                {
                    if (sh.StateEnum == StateEnum.INPROCESS)
                    {
                        sh.TotalShiftWeight = GetTotalWeight(sh);
                    }
                }
            }

            return(shifts.OrderBy(x => x.Date).ThenBy(x => x.FactoryId).ThenBy(x => x.Number).ToList());
        }
Exemple #9
0
 public IQueryable <Shift> Search(ShiftSearchModel searchModel)
 {
     return(rep.Search(searchModel));
 }