public ActionResult Index(BSOListModel bsoListModel, string sortField) { bsoListModel.SortField = sortField; bsoListModel.SortOrder = bsoListModel.SortOrder == "ASC" ? "DESC" : "ASC"; if (Role.Registrator.Id == Role.GetRealRole(CurrentUser).Id) { bsoListModel.SearchCriteriaModel.DeliveryCenterIds = new List <long>() { CurrentUser.Department.Id }; bsoListModel.SearchCriteriaModel.DeliveryPointIds = new List <long>() { CurrentUser.DeliveryPoint.Id }; } if (Role.ResponsibleBSO.Id == Role.GetRealRole(CurrentUser).Id) { bsoListModel.SearchCriteriaModel.ResponsibleID = CurrentUser.Id; } BSOSearchCriteria criteria = bsoListModel.SearchCriteriaModel.GetBSOSearchCriteria(); List <SortCriteria <BSOSortField> > sortList = new List <SortCriteria <BSOSortField> >(); if (!string.IsNullOrEmpty(bsoListModel.SortField)) { SortCriteria <BSOSortField> temp = new SortCriteria <BSOSortField>(); temp.SortField = (BSOSortField)long.Parse(bsoListModel.SortField); temp.SortOrder = (SortOrder)((bsoListModel.SortOrder == "ASC") ? 1 : 0); sortList.Add(temp); } DataPage <BSOInfo> bsos = bsoBusinessLogic.BSO_Find( criteria, sortList, new PageRequest() { PageNumber = bsoListModel.PageNumber, PageSize = bsoListModel.PageSize }); BSOListModel model = new BSOListModel() { Items = bsos.Data .Select(item => new BSOBaseInfoModel(item)), SearchCriteriaModel = new BSOSearchCriteriaModel( criteria), PageNumber = bsoListModel.PageNumber, PageSize = bsoListModel.PageSize, TotalCount = bsos.TotalCount, SortField = bsoListModel.SortField, SortOrder = bsoListModel.SortOrder, }; model.GetAvailableBSOStatus(bsoListModel.SearchCriteriaModel.StatusId, true); model.SearchCriteriaModel.NewStatusDate = DateTime.Now; return(View(model)); }
public ActionResult GetBSOFailForm13(BSOFailForm13Model model) { BSOListModel bsoListModel = new BSOListModel(); bsoListModel.SearchCriteriaModel.StatusDateFrom = model.DateFrom; bsoListModel.SearchCriteriaModel.StatusDateTo = model.DateTo; bsoListModel.SearchCriteriaModel.DeliveryCenterIds = new List <long>() { CurrentUser.Department.Id }; bsoListModel.SearchCriteriaModel.StatusId = (long)ListBSOStatusID.FailOnResponsible; BSOSearchCriteria criteria = bsoListModel.SearchCriteriaModel.GetBSOSearchCriteria(); List <BSOInfo> bsos = bsoBusinessLogic.BSO_Find( criteria, new List <SortCriteria <BSOSortField> >(), new PageRequest() { PageNumber = 1, PageSize = int.MaxValue }).Data; criteria.StatusId = (long)ListBSOStatusID.FailGotoStorage; bsos.AddRange(bsoBusinessLogic.BSO_Find( criteria, new List <SortCriteria <BSOSortField> >(), new PageRequest() { PageNumber = 1, PageSize = int.MaxValue }).Data); criteria.StatusId = (long)ListBSOStatusID.FailOnStorage; bsos.AddRange(bsoBusinessLogic.BSO_Find( criteria, new List <SortCriteria <BSOSortField> >(), new PageRequest() { PageNumber = 1, PageSize = int.MaxValue }).Data); BSOFailForm13 printedForm = new BSOFailForm13(bsos, model.DateFrom, model.DateTo, CurrentUser.DepartmentDisplayName, CurrentUser.Fullname); return(File(printedForm.GetExcel(), System.Net.Mime.MediaTypeNames.Application.Octet, string.Format("Акт передачи испорченных бланков БСО (временных свидетельств). Форма №13.xls"))); }