示例#1
0
        public ActionResult Index(int?customerId, FacilityRequestViewModel collection)
        {
            var request = new FilteredModel <ServiceRequest>
            {
                PageIndex = collection.ThisPageIndex,
                Order     = collection.PageOrder,
                OrderBy   = collection.PageOrderBy
            };
            var mappedModel = _mapper.Map <ServiceRequest>(collection);

            if (!collection.Latitude.HasValue || !collection.Longitude.HasValue)
            {
                mappedModel.Location = null;
            }
            var offset = (request.PageIndex - 1) * request.PageSize;

            mappedModel.StartTime = mappedModel.EndTime = null;
            mappedModel.Location  = null;
            var result = _mapper.Map <IList <FacilityRequestViewModel> >(_facilityRequestService.GetPaging(mappedModel, out long totalCount, request.OrderBy, request.Order, offset, request.PageSize));

            if (!result.Any() && totalCount > 0 && request.PageIndex > 1)
            {
                request.PageIndex = (int)(totalCount / request.PageSize);
                if (totalCount % request.PageSize > 0)
                {
                    request.PageIndex++;
                }
                result = _mapper.Map <IList <FacilityRequestViewModel> >(_facilityRequestService.GetPaging(mappedModel, out totalCount, request.OrderBy, request.Order, offset, request.PageSize));
            }
            ViewBag.OnePageOfEntries = new StaticPagedList <FacilityRequestViewModel>(result, request.PageIndex, request.PageSize, (int)totalCount);
            ViewBag.SearchModel      = collection;
            ViewBag.CustomerId       = collection.CustomerId;
            return(View());
        }
示例#2
0
        public ActionResult Index(ReviewViewModel collection)
        {
            long totalCount;
            var  request = new FilteredModel <BusinessReview>
            {
                PageIndex = collection.ThisPageIndex,
                Order     = collection.PageOrder,
                OrderBy   = collection.PageOrderBy
            };
            var offset = (request.PageIndex - 1) * request.PageSize;
            var result = _mapper.Map <IList <ReviewViewModel> >(_reviewService.GetPaging(_mapper.Map <BusinessReview>(collection), out totalCount, request.OrderBy, request.Order, offset, request.PageSize));

            if (!result.Any() && totalCount > 0 && request.PageIndex > 1)
            {
                request.PageIndex = (int)(totalCount / request.PageSize);
                if (totalCount % request.PageSize > 0)
                {
                    request.PageIndex++;
                }
                result = _mapper.Map <IList <ReviewViewModel> >(_reviewService.GetPaging(_mapper.Map <BusinessReview>(collection), out totalCount, request.OrderBy, request.Order, offset, request.PageSize));
            }
            ViewBag.OnePageOfEntries = new StaticPagedList <ReviewViewModel>(result, request.PageIndex, request.PageSize, (int)totalCount);
            ViewBag.SearchModel      = collection;
            return(View());
        }
示例#3
0
        public ActionResult Index(CustomerViewModel collection)
        {
            var request = new FilteredModel <User>
            {
                PageIndex = collection.ThisPageIndex,
                Order     = collection.PageOrder,
                OrderBy   = collection.PageOrderBy
            };
            var offset = (request.PageIndex - 1) * request.PageSize;
            var user   = _mapper.Map <User>(collection);

            user.Password = null;
            var result = _mapper.Map <IList <CustomerViewModel> >(_customerService.GetPaging(user, out long totalCount, request.OrderBy, request.Order, offset, request.PageSize));

            if (!result.Any() && totalCount > 0 && request.PageIndex > 1)
            {
                request.PageIndex = (int)(totalCount / request.PageSize);
                if (totalCount % request.PageSize > 0)
                {
                    request.PageIndex++;
                }
                result = _mapper.Map <IList <CustomerViewModel> >(_customerService.GetPaging(user, out totalCount, request.OrderBy, request.Order, offset, request.PageSize));
            }
            ViewBag.OnePageOfEntries = new StaticPagedList <CustomerViewModel>(result, request.PageIndex, request.PageSize, (int)totalCount);
            ViewBag.SearchModel      = collection;
            return(View());
        }
示例#4
0
        public ActionResult Index(ProviderViewModel collection)
        {
            if (!string.IsNullOrWhiteSpace(collection.CellPhone) && collection.CellPhone.StartsWith("0"))
            {
                collection.CellPhone = collection.CellPhone.Remove(0, 1);
            }
            var request = new FilteredModel <User>
            {
                PageIndex = collection.ThisPageIndex,
                Order     = collection.PageOrder,
                OrderBy   = collection.PageOrderBy
            };
            var offset = (request.PageIndex - 1) * request.PageSize;
            var user   = _mapper.Map <User>(collection);

            user.Password = null;
            var result = _mapper.Map <IList <ProviderViewModel> >(_providerService.GetPaging(user, out long totalCount, request.OrderBy, request.Order, offset, request.PageSize));

            if (!result.Any() && totalCount > 0 && request.PageIndex > 1)
            {
                request.PageIndex = (int)(totalCount / request.PageSize);
                if (totalCount % request.PageSize > 0)
                {
                    request.PageIndex++;
                }
                result = _mapper.Map <IList <ProviderViewModel> >(_providerService.GetPaging(user, out totalCount, request.OrderBy, request.Order, offset, request.PageSize));
            }
            ViewBag.OnePageOfEntries = new StaticPagedList <ProviderViewModel>(result, request.PageIndex, request.PageSize, (int)totalCount);
            ViewBag.SearchModel      = collection;
            return(View());
        }
示例#5
0
        public async Task <GetAllItemsEditionResponceModel> FilteredAsync(FilteredModel filteredModel, PaginationModel paginationModel)
        {
            var types = filteredModel.Types.Select(v => ((int)v).ToString()).Join(",");
            var query = @"SELECT BIG_COUNT(Id) FROM PrintingEditions WHERE type IN STRING_SPLIT(@types, ',')
                AND (@PriceMin is null OR @PriceMin <= Price)
                AND (@PriceMax is null OR @PriceMax >= Price)
                AND (@SearchText is null OR CHARINDEX(UPPER(@SearchText), UPPER(Title)) > 0) ORDER BY Price " + filteredModel.SortType.GetDescription() +
                        @"SELECT P.*, A.[Name] AS AuthorName FROM PrintingEditions AS P
            LEFT JOIN AuthorInPrintingEditions AS AP ON AP.PrintingEditionId = P.Id
            LEFT JOIN Authors AS A ON AP.AuthorId = A.Id 
            WHERE type IN STRING_SPLIT(@types, ',') 
            AND (@PriceMin is null OR @PriceMin <= Price) 
            AND (@PriceMax is null OR @PriceMax >= Price) 
            AND (@SearchText is null OR CHARINDEX(UPPER(@SearchText), UPPER(Title)) > 0) ORDER BY Price " + filteredModel.SortType.GetDescription() +
                        " OFFSET @start ROWS FETCH NEXT @count ROWS ONLY";

            using (var connection = new SqlConnection(_connectionString))
            {
                connection.Open();
                using (var multi = connection.QueryMultiple(query, new { types, filteredModel.PriceMin, filteredModel.PriceMax,
                                                                         filteredModel.SearchText, paginationModel.Start, paginationModel.Count }))
                {
                    var responseModels = new GetAllItemsEditionResponceModel();
                    responseModels.Count = await multi.ReadFirstAsync <long>();

                    responseModels.ResponseModels = (await multi.ReadAsync <GetAllItemsEditionItemResponseModel>()).AsList();
                    return(responseModels);
                }
            }
        }
        public ActionResult Index(RoleViewModel model)
        {
            try
            {
                ViewBag.SearchModel = model;
                var request = new FilteredModel <Role>();
                var offset  = (model.ThisPageIndex - 1) * model.ThisPageSize;

                var result = _mapper.Map <IList <RoleViewModel> >(_roleService.GetPaging(_mapper.Map <Role>(model), out long totalCount, model.PageOrderBy, model.PageOrder, offset, model.ThisPageSize));
                ViewBag.OnePageOfEntries = new StaticPagedList <RoleViewModel>(result, model.ThisPageIndex, model.ThisPageSize, (int)totalCount);
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
                if (ex.InnerException != null && ex.InnerException.Source.Equals(GeneralMessages.ExceptionSource))
                {
                    ModelState.AddModelError(string.Empty, ex.Message);
                }
                else
                {
                    ModelState.AddModelError(string.Empty, GeneralMessages.UnexpectedError);
                }
            }
            return(View());
        }
示例#7
0
 public ActionResult Index(int?providerId)
 {
     ViewBag.ProviderId = providerId;
     try
     {
         ViewBag.SearchModel = new BusinessViewModel {
         };
         var request = new FilteredModel <Business> {
         };
         var offset  = (request.PageIndex - 1) * request.PageSize;
         var test    = _businessService.GetPaging(new Business {
             ProviderId = providerId
         }, out long totalCount1, request.OrderBy, request.Order, offset, request.PageSize);
         var result = _mapper.Map <IList <BusinessViewModel> >(_businessService.GetPaging(new Business {
             ProviderId = providerId
         }, out long totalCount, request.OrderBy, request.Order, offset, request.PageSize));
         ViewBag.OnePageOfEntries = new StaticPagedList <BusinessViewModel>(result, request.PageIndex, request.PageSize, (int)totalCount);
     }
     catch (Exception ex)
     {
         _logger.Error(ex);
         if (ex.InnerException != null && ex.InnerException.Source.Equals(GeneralMessages.ExceptionSource))
         {
             ModelState.AddModelError(string.Empty, ex.Message);
         }
         else
         {
             ModelState.AddModelError(string.Empty, GeneralMessages.UnexpectedError);
         }
     }
     return(View());
 }
示例#8
0
 public ActionResult Index()
 {
     try
     {
         ViewBag.SearchModel = new AutomatedMessageViewModel {
             PageOrderBy = nameof(AutomatedMessageViewModel.Id)
         };
         var request = new FilteredModel <AutomatedMessage> {
             OrderBy = nameof(AutomatedMessageViewModel.Id)
         };
         var result = _mapper.Map <IList <AutomatedMessageViewModel> >(_automatedMessageService.GetPaging(new AutomatedMessage(), out long totalCount, request.OrderBy, request.Order, (request.PageIndex - 1) * request.PageSize, request.PageSize));
         ViewBag.OnePageOfEntries = new StaticPagedList <AutomatedMessageViewModel>(result, request.PageIndex, request.PageSize, (int)totalCount);
     }
     catch (Exception ex)
     {
         _logger.Error(ex);
         if (ex.InnerException != null && ex.InnerException.Source.Equals(GeneralMessages.ExceptionSource))
         {
             ModelState.AddModelError(string.Empty, ex.Message);
         }
         else
         {
             ModelState.AddModelError(string.Empty, GeneralMessages.UnexpectedError);
         }
     }
     return(View());
 }
示例#9
0
        public ActionResult HistoryTimeLine(int id, int page = 1, int pageSize = 10)
        {
            ViewBag.Page = page;
            var request = new FilteredModel <Activity> {
                PageIndex = page, PageSize = pageSize
            };
            var offset      = (request.PageIndex - 1) * request.PageSize;
            var searchModel = new Activity
            {
                EntityTypeId = (byte)GeneralEnums.EntityType.Business,
                EntityId     = id
            };
            var result = _activityService.History(searchModel, out long totalCount, skip: offset, take: request.PageSize);
            var data   = new List <BusinessViewModel>();

            foreach (var activity in result)
            {
                try
                {
                    var jobject  = JObject.Parse(activity.Data);
                    var settings = new JsonSerializerSettings().AddSqlConverters();
                    var newData  = JsonConvert.DeserializeObject <Business>(jobject["Business"].ToString(), settings);
                    newData.Location = null;
                    var loc = jobject["Business"]["Location"];
                    if (loc != null)
                    {
                        try
                        {
                            var lat = float.Parse(loc["Lat"].ToString());
                            var lng = float.Parse(loc["Lng"].ToString());
                            newData.Location = SqlGeography.Point(lat, lng, 4326);
                        }
                        catch { }
                    }
                    newData.CreatedAt = activity.CreatedAt;
                    newData.CreatorId = activity.CreatorId;
                    if (newData.CreatorId != null)
                    {
                        var admin = _adminService.GetById(newData.CreatorId.Value);
                        newData.CreatorName = (admin != null ? admin.FullName : "نامشخص");
                    }
                    var p = _mapper.Map <BusinessViewModel>(newData);
                    p.ActionTypeId = (GeneralEnums.ActionType)activity.ActionTypeId;
                    if (p.GeoId.HasValue)
                    {
                        var geo = _geoService.GetById(p.GeoId.Value);
                        p.GeoName = (geo != null ? geo.Name : "داده نامعتبر");
                    }
                    data.Add(p);
                }
                catch (Exception ex)
                {
                    data.Add(new BusinessViewModel {
                        Id = -1
                    });
                }
            }
            ViewData["page"] = page;
            return(PartialView("_HistoryTimeLine", data));
        }
        public ActionResult Index(ServiceRequestPreInvoiceViewModel collection)
        {
            var request = new FilteredModel <ServiceRequestPreInvoice>
            {
                PageIndex = collection.ThisPageIndex,
                Order     = collection.PageOrder,
                OrderBy   = collection.PageOrderBy
            };
            var offset = (request.PageIndex - 1) * request.PageSize;
            var result = mapper.Map <IList <ServiceRequestPreInvoiceViewModel> >(serviceRequestPreInvoiceService.GetPaging(mapper.Map <ServiceRequestPreInvoice>(collection), out long totalCount, request.OrderBy, request.Order, offset, request.PageSize));

            if (!result.Any() && totalCount > 0 && request.PageIndex > 1)
            {
                request.PageIndex = (int)(totalCount / request.PageSize);
                if (totalCount % request.PageSize > 0)
                {
                    request.PageIndex++;
                }
                result = mapper.Map <IList <ServiceRequestPreInvoiceViewModel> >(serviceRequestPreInvoiceService.GetPaging(mapper.Map <ServiceRequestPreInvoice>(collection), out totalCount, request.OrderBy, request.Order, offset, request.PageSize));
            }
            ViewBag.OnePageOfEntries = new StaticPagedList <ServiceRequestPreInvoiceViewModel>(result, request.PageIndex, request.PageSize, (int)totalCount);
            ViewBag.SearchModel      = collection;
            ViewBag.ProviderId       = collection.ProviderId;
            return(View());
        }
 public ActionResult Index(int?commentEntityId, byte?commentEntityTypeId)
 {
     ViewBag.commentEntityId = commentEntityId;
     try
     {
         ViewBag.SearchModel = new CommentViewModel {
             CommentEntityTypeId = (GeneralEnums.CommentEntityType?)commentEntityTypeId, CommentEntityId = commentEntityId
         };
         var request = new FilteredModel <Comment>();
         var offset  = (request.PageIndex - 1) * request.PageSize;
         var result  = _mapper.Map <IList <CommentViewModel> >(_commentService.GetPaging(new Comment {
             CommentEntityId = commentEntityId, CommentEntityTypeId = commentEntityTypeId
         }, out long totalCount, request.OrderBy, request.Order, offset, request.PageSize));
         ViewBag.OnePageOfEntries = new StaticPagedList <CommentViewModel>(result, request.PageIndex, request.PageSize, (int)totalCount);
     }
     catch (Exception ex)
     {
         _logger.Error(ex);
         if (ex.InnerException != null && ex.InnerException.Source.Equals(GeneralMessages.ExceptionSource))
         {
             ModelState.AddModelError(string.Empty, ex.Message);
         }
         else
         {
             ModelState.AddModelError(string.Empty, GeneralMessages.UnexpectedError);
         }
     }
     return(View());
 }
 public ActionResult Index(int id)
 {
     try
     {
         var business = businessService.GetById(id);
         if (business != null)
         {
             ViewBag.BusinessTitle = business.Title;
         }
         ViewBag.SearchModel = new ServiceRequestPreInvoiceViewModel {
             BusinessId = id
         };
         var request = new FilteredModel <ServiceRequestPreInvoice> {
         };
         var offset  = (request.PageIndex - 1) * request.PageSize;
         var result  = mapper.Map <IList <ServiceRequestPreInvoiceViewModel> >(serviceRequestPreInvoiceService.GetPaging(new ServiceRequestPreInvoice {
             BusinessId = id
         }, out long totalCount, request.OrderBy, request.Order, offset, request.PageSize));
         ViewBag.OnePageOfEntries = new StaticPagedList <ServiceRequestPreInvoiceViewModel>(result, request.PageIndex, request.PageSize, (int)totalCount);
     }
     catch (Exception ex)
     {
         logger.Error(ex);
         if (ex.InnerException != null && ex.InnerException.Source.Equals(GeneralMessages.ExceptionSource))
         {
             ModelState.AddModelError(string.Empty, ex.Message);
         }
         else
         {
             ModelState.AddModelError(string.Empty, GeneralMessages.UnexpectedError);
         }
     }
     return(View());
 }
示例#13
0
        public ActionResult Index(UploadedPinFactorViewModel model)
        {
            long totalCount;

            model.Id            = null;
            ViewBag.SearchModel = model;
            var request = new FilteredModel <UploadedPinFactorViewModel>
            {
                PageIndex = model.ThisPageIndex,
                Order     = model.PageOrder,
                OrderBy   = model.PageOrderBy
            };
            var searchModel = _mapper.Map <UploadedPinFactor>(model);
            var result      = _mapper.Map <IList <UploadedPinFactorViewModel> >(_uploadedPinFactorService.GetPaging(searchModel, out totalCount, request.OrderBy, request.Order, (request.PageIndex - 1) * request.PageSize, request.PageSize));

            if (!result.Any() && totalCount > 0 && request.PageIndex > 1)
            {
                request.PageIndex = (int)(totalCount / request.PageSize);
                if (totalCount % request.PageSize > 0)
                {
                    request.PageIndex++;
                }
                result = _mapper.Map <IList <UploadedPinFactorViewModel> >(_uploadedPinFactorService.GetPaging(_mapper.Map <UploadedPinFactor>(model), out totalCount, request.OrderBy, request.Order, (request.PageIndex - 1) * request.PageSize, request.PageSize));
            }
            ViewBag.OnePageOfEntries = new StaticPagedList <UploadedPinFactorViewModel>(result, request.PageIndex, request.PageSize, (int)totalCount);
            return(View());
        }
示例#14
0
 public ActionResult Index()
 {
     try
     {
         ViewBag.SearchModel = new FacilityViewModel();
         var request = new FilteredModel <Facility>();
         var offset  = (request.PageIndex - 1) * request.PageSize;
         var result  = _mapper.Map <IList <FacilityViewModel> >(_facilityService.GetPaging(new Facility(), out long totalCount, request.OrderBy, request.Order, offset, request.PageSize));
         ViewBag.OnePageOfEntries = new StaticPagedList <FacilityViewModel>(result, request.PageIndex, request.PageSize, (int)totalCount);
         return(View());
     }
     catch (Exception ex)
     {
         _logger.Error(ex);
         if (ex.InnerException != null && ex.InnerException.Source.Equals(GeneralMessages.ExceptionSource))
         {
             ModelState.AddModelError(string.Empty, ex.Message);
         }
         else
         {
             ModelState.AddModelError(string.Empty, GeneralMessages.UnexpectedError);
         }
         return(View());
     }
 }
示例#15
0
        public ActionResult Businesses(int id, BusinessViewModel collection)
        {
            var request = new FilteredModel <Facility>
            {
                PageIndex = collection.ThisPageIndex,
                Order     = collection.PageOrder,
                OrderBy   = collection.PageOrderBy
            };
            var offset = (request.PageIndex - 1) * request.PageSize;
            var result = _mapper.Map <IList <BusinessViewModel> >(_businessService.GetPagingByFacilityId(id, _mapper.Map <Business>(collection), out long totalCount, request.OrderBy, request.Order, offset, request.PageSize));

            if (!result.Any() && totalCount > 0 && request.PageIndex > 1)
            {
                request.PageIndex = (int)(totalCount / request.PageSize);
                if (totalCount % request.PageSize > 0)
                {
                    request.PageIndex++;
                }
                result = _mapper.Map <IList <BusinessViewModel> >(_businessService.GetPagingByFacilityId(id, _mapper.Map <Business>(collection), out totalCount, request.OrderBy, request.Order, offset, request.PageSize));
            }
            ViewBag.OnePageOfEntries = new StaticPagedList <BusinessViewModel>(result, request.PageIndex, request.PageSize, (int)totalCount);
            ViewBag.SearchModel      = collection;
            ViewBag.Id = id;
            return(View());
        }
        public ActionResult HistoryTimeLine(int id, int page = 1, int pageSize = 10)
        {
            ViewBag.Page = page;
            var request = new FilteredModel <Activity> {
                PageIndex = page, PageSize = pageSize
            };
            var offset      = (request.PageIndex - 1) * request.PageSize;
            var searchModel = new Activity
            {
                EntityTypeId = (byte)GeneralEnums.EntityType.Business2Facility,
                ActionTypeId = (byte)GeneralEnums.ActionType.EditRequest,
                EntityId     = id
            };
            var result = _activityService.History(searchModel, out long totalCount, skip: offset, take: request.PageSize);
            var data   = new List <Business2FacilityHistoryViewModel>();

            foreach (var activity in result)
            {
                try
                {
                    var jobject = JObject.Parse(activity.Data);
                    var newData = jobject["Business2Facility"]["Items"].ToObject <List <Business2FacilityViewModel> >();
                    //var xmlSerializer = new XmlSerializer(typeof(XmlBusiness2Facility), new XmlRootAttribute { ElementName = nameof(Business2Facility), IsNullable = true });
                    //var xmlBusiness = (XmlBusiness2Facility)xmlSerializer.Deserialize(activity.Data.CreateReader());
                    //var newData = _mapper.Map<List<Business2Facility>>(xmlBusiness.Business2Facility);
                    var history = new Business2FacilityHistoryViewModel
                    {
                        Items        = _mapper.Map <List <Business2FacilityViewModel> >(newData),
                        ActionTypeId = (GeneralEnums.ActionType)activity.ActionTypeId,
                        CreatedAt    = new PersianDateTime(activity.CreatedAt).ToString(),
                        CreatorId    = activity.CreatorId
                    };
                    if (history.CreatorId != null)
                    {
                        var admin = _adminService.GetById(history.CreatorId.Value);
                        history.CreatorName = (admin != null ? admin.FullName : "نامشخص");
                    }
                    foreach (var item in history.Items)
                    {
                        var facility = _facilityService.GetById(item.FacilityId.Value);
                        item.FacilityTitle = (facility != null ? facility.Title : "داده نامعتبر");
                    }
                    data.Add(history);
                }
                catch
                {
                    data.Add(new Business2FacilityHistoryViewModel {
                        Items = new List <Business2FacilityViewModel> {
                            new Business2FacilityViewModel {
                                Id = -1
                            }
                        }
                    });
                }
            }
            ViewData["page"] = page;
            return(PartialView("_HistoryTimeLine", data));
        }
示例#17
0
        static Games()
        {
            model.PropertyChanged   += new PropertyChangedEventHandler(GamesHandler_PropertyChanged);
            model.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(GamesHandler_CollectionChanged);


            _DetectedGames = new FilteredModel <GameID, GameEntry>(model);
            _DetectedGames.AddFilter("IsDetected", true);
        }
示例#18
0
        public ActionResult List(PredictionViewModel collection)
        {
            try
            {
                if (collection.HomeClubId.HasValue && collection.HomeClubId.Value == 0)
                {
                    collection.HomeClubId = null;
                }
                if (collection.MatchId.HasValue && collection.MatchId.Value == 0)
                {
                    collection.MatchId = null;
                }

                var request = new FilteredModel <PredictionViewModel>
                {
                    PageIndex = collection.ThisPageIndex,
                    Order     = collection.PageOrder,
                    OrderBy   = collection.PageOrderBy,
                    PageSize  = collection.ThisPageSize
                };

                var offset = (request.PageIndex - 1) * request.PageSize;
                var result = _mapper.Map <IList <PredictionViewModel> >(_predictionService.GetPaging(_mapper.Map <Prediction>(collection), out long totalCount, request.OrderBy, request.Order, offset, request.PageSize));
                if (!result.Any() && totalCount > 0 && request.PageIndex > 1)
                {
                    request.PageIndex = (int)(totalCount / request.PageSize);
                    if (totalCount % request.PageSize > 0)
                    {
                        request.PageIndex++;
                    }
                    offset = (request.PageIndex - 1) * request.PageSize;
                    result = _mapper.Map <IList <PredictionViewModel> >(_predictionService.GetPaging(_mapper.Map <Prediction>(collection), out totalCount, request.OrderBy, request.Order, (request.PageIndex - 1) * request.PageSize, request.PageSize));
                }
                ViewBag.OnePageOfEntries = new StaticPagedList <PredictionViewModel>(result, request.PageIndex, request.PageSize, (int)totalCount);
                ViewBag.SearchModel      = collection;
                ViewBag.Statistics       = _mapper.Map <PredictionStatisticsViewModel>(_predictionStatisticsService.GetStatistics(_mapper.Map <Prediction>(collection)));
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
                if (ex.InnerException != null && ex.InnerException.Source.Equals(GeneralMessages.ExceptionSource))
                {
                    ModelState.AddModelError(string.Empty, ex.Message);
                }
                else
                {
                    ModelState.AddModelError(string.Empty, GeneralMessages.UnexpectedError);
                }
            }

            return(Request.IsAjaxRequest()
                ? (ActionResult)PartialView("_PredictionGrid", ViewBag.OnePageOfEntries)
                : View());
        }
示例#19
0
        public ActionResult SetPriority(int id)
        {
            var request = new FilteredModel <Facility>
            {
                PageSize = int.MaxValue,
                OrderBy  = nameof(Facility.Priority),
                Order    = "desc"
            };
            var result = _mapper.Map <IList <FacilityViewModel> >(_facilityService.GetPaging(new Facility {
                ParentId = id
            }, out long totalCount, request.OrderBy, request.Order, 0, request.PageSize));

            return(View(result));
        }
示例#20
0
        public async Task <PrintingEditionModel> GetSortedAsync(bool[] categorys) //add filter
        {
            var filteredModel   = new FilteredModel();
            var paginationModel = new PaginationModel();
            var responseModels  = await _printingEditionRepository.FilteredAsync(filteredModel, paginationModel);

            var printingEditionModel = _mapper.ResponseModelToModelItem(responseModels.ResponseModels);

            foreach (var item in printingEditionModel.Items)
            {
                // item.AuthorsName = d
            }
            return(printingEditionModel);
        }
示例#21
0
        public IEnumerable <MergedTablesDTO> GetFiltered(FilteredModel model)
        {
            var filterModel = new Filter(model.Id, model.FtableId, model.LastName, model.SomeDate,
                                         model.SecondFloatNumber, model.Checker, model.Access, model.FirstName, model.TableDate,
                                         model.SomeFloatNumber, model.SomeIntNumber);

            var joinedTables = repositoryJoinedTables.GetFiltered(filterModel);
            var mergedList   = new List <MergedTablesDTO>();

            foreach (var j in joinedTables)
            {
                mergedList.Add(new MergedTablesDTO(j));
            }

            return(mergedList);
        }
        private IFilteredModel <TEntity> InitFilterHandler <TEntity>(object additionalParams = default) where TEntity : IBaseEntity
        {
            var service = HttpContext.RequestServices.GetService <ICommonService <TEntity> >();
            var builder = HttpContext.RequestServices.GetService <IQueryBuilder>();
            var handler = new FilteredModel <TEntity>(builder, service);

            var contentBuilder = HttpContext.RequestServices.GetService <FilterContentBuilder <TEntity> >();

            if (additionalParams != default)
            {
                contentBuilder.SetAdditionalParams(additionalParams);
            }
            contentBuilder.ConfigureFilter(handler);
            contentBuilder.ConfigureSorting(handler);
            return(handler);
        }
 public ActionResult Index(int?businessId)
 {
     try
     {
         if (businessId.HasValue)
         {
             var business = _businessService.GetById(businessId.Value);
             if (business != null)
             {
                 ViewBag.BusinessTitle = business.Title;
             }
         }
         ViewBag.SearchModel = new BusinessAttachmentViewModels();
         long totalCount;
         var  request = new FilteredModel <BusinessAttachment>();
         var  offset  = (request.PageIndex - 1) * request.PageSize;
         var  result  =
             _mapper.Map <IList <BusinessAttachmentViewModels> >(_businessAttachmentService.GetPaging(new BusinessAttachment()
         {
             BusinessId = businessId.Value
         },
                                                                                                      out totalCount,
                                                                                                      request.OrderBy,
                                                                                                      request.Order,
                                                                                                      offset,
                                                                                                      request.PageSize));
         ViewBag.OnePageOfEntries        = new StaticPagedList <BusinessAttachmentViewModels>(result, request.PageIndex, request.PageSize, (int)totalCount);
         HttpContext.Cache["BusinessId"] = businessId;
         return(View());
     }
     catch (Exception ex)
     {
         _logger.Error(ex);
         if (ex.InnerException != null && ex.InnerException.Source.Equals(GeneralMessages.ExceptionSource))
         {
             ModelState.AddModelError(string.Empty, ex.Message);
         }
         else
         {
             ModelState.AddModelError(string.Empty, GeneralMessages.UnexpectedError);
         }
         return(View());
     }
 }
        public ActionResult LeaderBoardsList(UserLeaderBoardViewModel collection)
        {
            try
            {
                var request = new FilteredModel <UserLeaderBoardViewModel>
                {
                    PageIndex = collection.ThisPageIndex,
                    Order     = collection.PageOrder,
                    OrderBy   = collection.PageOrderBy,
                    PageSize  = collection.ThisPageSize
                };

                var offset = (request.PageIndex - 1) * request.PageSize;
                var result = _mapper.Map <List <UserLeaderBoardViewModel> >(_userLeaderBoardService.GetTotalPoints(_mapper.Map <UserLeaderBoard>(collection), out long totalCount, request.OrderBy, request.Order, offset, request.PageSize));

                if (!result.Any() && totalCount > 0 && request.PageIndex > 1)
                {
                    request.PageIndex = (int)(totalCount / request.PageSize);
                    if (totalCount % request.PageSize > 0)
                    {
                        request.PageIndex++;
                    }
                    offset = (request.PageIndex - 1) * request.PageSize;
                    result = _mapper.Map <List <UserLeaderBoardViewModel> >(_userLeaderBoardService.GetTotalPoints(_mapper.Map <UserLeaderBoard>(collection), out totalCount, request.OrderBy, request.Order, (request.PageIndex - 1) * request.PageSize, request.PageSize));
                }
                ViewBag.OnePageOfEntries = new StaticPagedList <UserLeaderBoardViewModel>(result, request.PageIndex, request.PageSize, (int)totalCount);
                ViewBag.SearchModel      = collection;
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
                if (ex.InnerException != null && ex.InnerException.Source.Equals(GeneralMessages.ExceptionSource))
                {
                    ModelState.AddModelError(string.Empty, ex.Message);
                }
                else
                {
                    ModelState.AddModelError(string.Empty, GeneralMessages.UnexpectedError);
                }
            }
            return((ActionResult)PartialView("_UserLeaderBoards", ViewBag.OnePageOfEntries));
        }
示例#25
0
        public ActionResult HistoryTimeLine(int id, int page = 1, int pageSize = 10)
        {
            ViewBag.Page = page;
            var request = new FilteredModel <Activity> {
                PageIndex = page, PageSize = pageSize
            };
            var offset      = (request.PageIndex - 1) * request.PageSize;
            var searchModel = new Activity {
                EntityTypeId = (byte)GeneralEnums.EntityType.User,
                EntityId     = id
            };
            var result = _activityService.History(searchModel, out long totalCount, skip: offset, take: request.PageSize);
            var data   = new List <ProviderViewModel>();

            foreach (var activity in result)
            {
                try
                {
                    var jobject = JObject.Parse(activity.Data);
                    var newData = jobject["User"].ToObject <User>();
                    newData.CreatedAt = activity.CreatedAt;
                    var p = _mapper.Map <ProviderViewModel>(newData);
                    p.ActionTypeId = (GeneralEnums.ActionType)activity.ActionTypeId;
                    p.CreatorId    = activity.CreatorId;
                    if (p.CreatorId != null)
                    {
                        var admin = _adminService.GetById(p.CreatorId.Value);
                        p.CreatorName = (admin != null ? admin.FullName : "نامشخص");
                    }
                    data.Add(p);
                }
                catch
                {
                    data.Add(new ProviderViewModel {
                        Id = -1
                    });
                }
            }
            ViewData["page"] = page;
            return(PartialView("_HistoryTimeLine", data));
        }
示例#26
0
        public ActionResult Index(AutomatedMessageViewModel model)
        {
            var request = new FilteredModel <AutomatedMessage>
            {
                PageIndex = model.ThisPageIndex,
                Order     = model.PageOrder,
                OrderBy   = model.PageOrderBy
            };
            var result = _mapper.Map <IList <AutomatedMessageViewModel> >(_automatedMessageService.GetPaging(_mapper.Map <AutomatedMessage>(model), out long totalCount, request.OrderBy, request.Order, (request.PageIndex - 1) * request.PageSize, request.PageSize));

            if (!result.Any() && totalCount > 0 && request.PageIndex > 1)
            {
                request.PageIndex = (int)(totalCount / request.PageSize);
                if (totalCount % request.PageSize > 0)
                {
                    request.PageIndex++;
                }
                result = _mapper.Map <IList <AutomatedMessageViewModel> >(_automatedMessageService.GetPaging(_mapper.Map <AutomatedMessage>(model), out totalCount, request.OrderBy, request.Order, (request.PageIndex - 1) * request.PageSize, request.PageSize));
            }
            ViewBag.OnePageOfEntries = new StaticPagedList <AutomatedMessageViewModel>(result, request.PageIndex, request.PageSize, (int)totalCount);
            ViewBag.SearchModel      = model;
            return(View());
        }
 public ActionResult Index(int?providerId, int?businessId)
 {
     ViewBag.ProviderId = providerId;
     ViewBag.BusinessId = businessId;
     try
     {
         if (businessId.HasValue)
         {
             var business = _businessService.GetById(businessId.Value);
             if (business != null)
             {
                 ViewBag.BusinessTitle = business.Title;
             }
         }
         ViewBag.SearchModel = new ProviderEvidenceDocViewModel();
         var request = new FilteredModel <ProviderEvidenceDoc>();
         var offset  = (request.PageIndex - 1) * request.PageSize;
         var result  = _mapper.Map <IList <ProviderEvidenceDocViewModel> >(_providerEvidenceDocService.GetPaging(new ProviderEvidenceDoc {
             ProviderId = providerId, BusinessId = businessId
         }, out long totalCount, request.OrderBy, request.Order, offset, request.PageSize));
         ViewBag.OnePageOfEntries = new StaticPagedList <ProviderEvidenceDocViewModel>(result, request.PageIndex, request.PageSize, (int)totalCount);
     }
     catch (Exception ex)
     {
         _logger.Error(ex);
         if (ex.InnerException != null && ex.InnerException.Source.Equals(GeneralMessages.ExceptionSource))
         {
             ModelState.AddModelError(string.Empty, ex.Message);
         }
         else
         {
             ModelState.AddModelError(string.Empty, GeneralMessages.UnexpectedError);
         }
     }
     return(View());
 }
示例#28
0
        public IActionResult Index(ChooseFilterModel filterData)
        {
            var filterModel = new FilteredModel();

            string[] strArray = filterData.FilterValue.Split(' ');
            var      log      = new LogTableDTO();

            log.WhenItUse = DateTime.Now;
            switch (filterData.TableName)
            {
            case "Id":
                List <int> l0 = new List <int>();
                foreach (var s in strArray)
                {
                    l0.Add(Int32.Parse(s));
                }

                filterModel.Id = l0;
                log.FilterName = "Id";
                dataService.AddLog(log);
                break;

            case "FtableId":
                List <int?> l1 = new List <int?>();
                foreach (var s in strArray)
                {
                    l1.Add(Int32.Parse(s));
                }

                filterModel.FtableId = l1;
                log.FilterName       = "FtableId";
                break;

            case "LastName":
                List <string> l2 = new List <string>();
                foreach (var s in strArray)
                {
                    l2.Add(s);
                }

                filterModel.LastName = l2;
                log.FilterName       = "LastName";

                break;

            case "SomeDate":
                List <DateTime?> l3 = new List <DateTime?>();
                foreach (var s in strArray)
                {
                    l3.Add(DateTime.Parse(s));
                }

                filterModel.SomeDate = l3;
                log.FilterName       = "SomeDate";

                break;

            case "SecondFloatNumber":
                List <double?> l4 = new List <double?>();
                foreach (var s in strArray)
                {
                    l4.Add(Double.Parse(s));
                }

                filterModel.SecondFloatNumber = l4;
                log.FilterName = "SecondFloatNumber";

                break;

            case "Checker":
                List <bool?> l5 = new List <bool?>();
                foreach (var s in strArray)
                {
                    l5.Add(Boolean.Parse(s));
                }

                filterModel.Checker = l5;
                log.FilterName      = "Checker";

                break;

            case "Access":
                List <bool?> l6 = new List <bool?>();
                foreach (var s in strArray)
                {
                    l6.Add(Boolean.Parse(s));
                }

                filterModel.Access = l6;
                log.FilterName     = "Access";

                break;

            case "FirstName":
                List <string> l7 = new List <string>();
                foreach (var s in strArray)
                {
                    l7.Add(s);
                }

                filterModel.FirstName = l7;
                log.FilterName        = "FirstName";

                break;

            case "TableDate":
                List <DateTime?> l8 = new List <DateTime?>();
                foreach (var s in strArray)
                {
                    l8.Add(DateTime.Parse(s));
                }

                filterModel.TableDate = l8;
                log.FilterName        = "TableDate";

                break;

            case "SomeFloatNumber":
                List <double?> l9 = new List <double?>();
                foreach (var s in strArray)
                {
                    l9.Add(Double.Parse(s));
                }

                filterModel.SomeFloatNumber = l9;
                log.FilterName = "SomeFloatNumber";

                break;

            case "SomeIntNumber":
                List <int?> l10 = new List <int?>();
                foreach (var s in strArray)
                {
                    l10.Add(Int32.Parse(s));
                }

                filterModel.SomeIntNumber = l10;
                log.FilterName            = "SomeIntNumber";


                break;
            }

            var result = dataService.GetFiltered(filterModel);

            return(View("Filter", result));
        }
        public ActionResult List(RoleViewModel collection)
        {
            try
            {
                var request = new FilteredModel <RoleViewModel>
                {
                    PageIndex = collection.ThisPageIndex,
                    Order     = collection.PageOrder,
                    OrderBy   = collection.PageOrderBy,
                    PageSize  = collection.ThisPageSize
                };

                var offset = (request.PageIndex - 1) * request.PageSize;
                var result = _mapper.Map <IList <RoleViewModel> >(_roleService.GetPaging(_mapper.Map <Role>(collection), out long totalCount, request.OrderBy, request.Order, offset, request.PageSize));
                if (!result.Any() && totalCount > 0 && request.PageIndex > 1)
                {
                    request.PageIndex = (int)(totalCount / request.PageSize);
                    if (totalCount % request.PageSize > 0)
                    {
                        request.PageIndex++;
                    }
                    offset = (request.PageIndex - 1) * request.PageSize;
                    result = _mapper.Map <IList <RoleViewModel> >(_roleService.GetPaging(_mapper.Map <Role>(collection), out totalCount, request.OrderBy, request.Order, (request.PageIndex - 1) * request.PageSize, request.PageSize));
                }
                ViewBag.OnePageOfEntries = new StaticPagedList <RoleViewModel>(result, request.PageIndex, request.PageSize, (int)totalCount);
                ViewBag.SearchModel      = collection;
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
                if (ex.InnerException != null && ex.InnerException.Source.Equals(GeneralMessages.ExceptionSource))
                {
                    ModelState.AddModelError(string.Empty, ex.Message);
                }
                else
                {
                    ModelState.AddModelError(string.Empty, GeneralMessages.UnexpectedError);
                }
            }

            return(Request.IsAjaxRequest()
                ? (ActionResult)PartialView("_RoleGrid", ViewBag.OnePageOfEntries)
                : View());


            //var request = new FilteredModel<Role>
            //{
            //    PageIndex = collection.ThisPageIndex,
            //    Order = collection.PageOrder,
            //    OrderBy = collection.PageOrderBy
            //};
            //var offset = (request.PageIndex - 1) * request.PageSize;
            //var result = _mapper.Map<IList<RoleViewModel>>(_roleService.GetPaging(_mapper.Map<Role>(collection), out long totalCount, request.OrderBy, request.Order, offset, request.PageSize));
            //if (!result.Any() && totalCount > 0 && request.PageIndex > 1)
            //{
            //    request.PageIndex = (int)(totalCount / request.PageSize);
            //    if (totalCount % request.PageSize > 0)
            //    {
            //        request.PageIndex++;
            //    }
            //    result = _mapper.Map<IList<RoleViewModel>>(_roleService.GetPaging(_mapper.Map<Role>(collection), out totalCount, request.OrderBy, request.Order, offset, request.PageSize));
            //}
            //ViewBag.OnePageOfEntries = new StaticPagedList<RoleViewModel>(result, request.PageIndex, request.PageSize, (int)totalCount);
            //ViewBag.SearchModel = collection;

            //return Request.IsAjaxRequest()
            //            ? (ActionResult)PartialView("_CategoryGrid", ViewBag.OnePageOfEntries)
            //            : View();
            //return View();
        }