Пример #1
0
 public Page(
     PageNumber pageNumber,
     PageConfiguration configuration)
 {
     this.PageNumber    = pageNumber;
     this.Configuration = configuration;
 }
Пример #2
0
        public ResponseModel <PageResultModel <MenuDto> > List(PageConfiguration configuration)
        {
            ResponseModel <PageResultModel <MenuDto> > response = new ResponseModel <PageResultModel <MenuDto> >();
            PageResultModel <MenuDto> menuRecords = new PageResultModel <MenuDto>();

            menuRecords.Records = new List <MenuDto>();
            try
            {
                response.IsSuccess = true;
                Func <Menu, bool> expression = m => !m.IsDeleted;
                if (!string.IsNullOrEmpty(configuration.Search))
                {
                    expression = m => !m.IsDeleted && (m.MenuName.Contains(configuration.Search) || m.MenuDescription.Contains(configuration.Search));
                }
                var records = _unitOfWork.Repository <Menu>().GetMultiple(configuration, expression);
                foreach (var item in records.Records)
                {
                    MenuDto dto = new MenuDto();
                    dto = Mapper <Menu, MenuDto> .Map(item, dto);

                    menuRecords.Records.Add(dto);
                }
                menuRecords.TotalPages   = records.TotalPages;
                menuRecords.TotalRecords = records.TotalRecords;
                menuRecords.PageNumber   = records.PageNumber;
                menuRecords.Showing      = records.Showing;
            }
            catch (Exception ex)
            {
                response.IsFailed  = true;
                response.ErrorCode = CommonConstants.ErrorCode.InternalServerError;
            }

            return(response);
        }
        /// <summary>
        /// Create <see cref="ContentsControllerTests"/>.
        /// </summary>
        public ContentsControllerTests()
        {
            // Dependencies initializations
            var connection = InMemoryConnectionHelper.SetupConnection();

            var services = new ServiceCollection();

            services.AddEntityFrameworkSqlite()
            .AddDbContext <DataDbContext>(options =>
                                          options.UseSqlite(connection),
                                          ServiceLifetime.Transient
                                          );

            var serviceProvider = services.BuildServiceProvider();

            var pageConfiguration = new PageConfiguration();

            _dataDbContext = serviceProvider.GetService <DataDbContext>();
            _dataDbContext.Database.EnsureCreated();

            var contentRepository           = new ContentViewerRepository(_dataDbContext);
            var humanReadableContentService = new HumanReadableContentRetrievalService(pageConfiguration, contentRepository);

            var languageManipulationService = new LanguageManipulationService();

            // Controller initialization
            _contentsController = new ContentsController(
                pageConfiguration,
                humanReadableContentService,
                languageManipulationService
                );
        }
        public async Task <IActionResult> Edit(int id, [Bind("PageConfigurationID,CustomerID,SendingNewsletter,ShowNetPrices,ProductsPerPage,InterfaceSkin,Language,Currency")] PageConfiguration pageConfiguration)
        {
            if (id != pageConfiguration.PageConfigurationID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(pageConfiguration);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PageConfigurationExists(pageConfiguration.PageConfigurationID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(pageConfiguration));
        }
Пример #5
0
        public ResponseModel <List <OfferDto> > GetRestaurantOffersUI(long restaurantId)
        {
            ResponseModel <List <OfferDto> > result = new ResponseModel <List <OfferDto> >();
            PageConfiguration configuration         = new PageConfiguration()
            {
                PageNumber = 1,
                PageSize   = 4
            };

            string[] excludeMapping = new string[] { "Offers", "CreatedDate", "UpdatedDate", "CreatedById", "UpdatedById", "Restaurant" };
            try
            {
                var entity = _unitOfWork.Repository <Offer>().GetMultiple(configuration, m => m.RestaurantId == restaurantId &&
                                                                          (m.OfferStartDate) <= DateTime.Now.Date &&
                                                                          (m.OfferEndDate) >= DateTime.Now.Date &&
                                                                          !m.IsDeleted).Records;
                List <OfferDto> records = new List <OfferDto>();
                foreach (var offer in entity)
                {
                    var dto = Mapper <Offer, OfferDto> .Map(offer, new OfferDto(), excludeMapping);

                    records.Add(dto);
                }
                result.ResponseObject = records;
                result.IsSuccess      = true;
            }
            catch (Exception ex)
            {
                result.IsFailed  = true;
                result.ErrorCode = CommonConstants.ErrorCode.InternalServerError;
            }
            return(result);
        }
Пример #6
0
        private IEnumerable <MenuItemDto> GetItems(Func <MenuItem, bool> expression, PageConfiguration configuration)
        {
            string[] include = new string[] { "Menu.MenuCategory", "Ratings" };
            IEnumerable <MenuItemDto> result = null;
            var entity = _unitOfWork.Repository <MenuItem>().GetMultiple(configuration, expression, include);

            if (entity.Records.Count > 0)
            {
                result = entity.Records.Select(m => new MenuItemDto
                {
                    ItemName         = m.ItemName,
                    ItemDetails      = m.ItemDetails,
                    Logo             = m.Logo,
                    Id               = m.Id,
                    Rating           = m.Ratings.Count > 0 ? m.Ratings.Average(n => n.Rate) : 0,
                    ItemPerUnitPrice = m.ItemPerUnitPrice,
                    Menu             = new MenuDto
                    {
                        MenuCategoryId = m.Menu.MenuCategoryId,
                        MenuCategory   = new MenuCategory
                        {
                            Name = m.Menu.MenuCategory.Name,
                            Id   = m.Menu.MenuCategory.Id
                        },
                        RestaurantId = m.Menu.RestaurantId,
                        MenuLogo     = m.Menu.MenuLogo,
                        MenuName     = m.Menu.MenuName
                    }
                });
            }
            return(result);
        }
        public async Task <IActionResult> GetMessages(PageConfiguration configuration)
        {
            ResponseModel <PageResultModel <Message> > response = new ResponseModel <PageResultModel <Message> >();

            response = MessageHelper <Message> .GetMessages(configuration);

            return(Ok(response));
        }
Пример #8
0
        public async Task <IActionResult> GetOffers(PageConfiguration configuration)
        {
            var result = _service.GetOffers(configuration);

            result = MessageHelper <PageResultModel <OfferDto> > .GetResponse(result);

            return(Ok(result));
        }
Пример #9
0
 public static MenuPage FromConfig(PageConfiguration config, int index, IActionFactory actionFactory)
 {
     return(new MenuPage(
                index,
                config.Help,
                config.Help2,
                CommandBindingCollection.FromCollection(config.CommandBindings, actionFactory),
                config.Items.Select((item, i) => PageItem.FromConfig(item, i, config.Items.Count, actionFactory))));
 }
        public async Task <IActionResult> List(PageConfiguration configuration)
        {
            configuration.UserId = User.Identity.Name;
            var result = _service.List(configuration);

            result = MessageHelper <PageResultModel <RestaurantDto> > .GetResponse(result);

            return(Ok(result));
        }
Пример #11
0
        public static ColumnsConfiguration CreateColumnsConfiguration(
            this Word.SectionProperties sectionProperties,
            PageConfiguration pageConfiguration,
            PageMargin pageMargin)
        {
            var columns = sectionProperties.GetSectionColumnConfigs(pageConfiguration, pageMargin);

            return(new ColumnsConfiguration(columns));
        }
        public async Task <IActionResult> Create([Bind("PageConfigurationID,CustomerID,SendingNewsletter,ShowNetPrices,ProductsPerPage,InterfaceSkin,Language,Currency")] PageConfiguration pageConfiguration)
        {
            if (ModelState.IsValid)
            {
                _context.Add(pageConfiguration);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(pageConfiguration));
        }
Пример #13
0
 public SectionProperties(
     PageConfiguration pageConfiguration,
     HeaderFooterConfiguration headerFooterConfiguration,
     PageMargin margin,
     bool StartOnNextPage)
 {
     this.PageConfiguration         = pageConfiguration;
     this.HeaderFooterConfiguration = headerFooterConfiguration;
     this.Margin          = margin;
     this.StartOnNextPage = StartOnNextPage;
 }
Пример #14
0
        public PageResultModel <T> GetMultiple(PageConfiguration configuration, Func <T, bool> predicate)
        {
            var entity = table.AsNoTracking().Where(predicate);
            PageResultModel <T> result = new PageResultModel <T>();

            result.TotalRecords = entity.Count();
            result.PageNumber   = configuration.PageNumber;
            result.TotalPages   = (int)Math.Ceiling((double)entity.Count() / configuration.PageSize);
            result.Records      = entity.Skip((configuration.PageNumber - 1) * configuration.PageSize).Take(configuration.PageSize).ToList();
            result.Showing      = result.Records.Count();
            return(result);
        }
Пример #15
0
 public void Configure(PageConfiguration pageEntity)
 {
     lock (pagesByKey)
     {
         if (pagesByKey.ContainsKey(pageEntity.Page))
         {
             pagesByKey[pageEntity.Page] = pageEntity;
         }
         else
         {
             pagesByKey.Add(pageEntity.Page, pageEntity);
         }
     }
 }
 public void Configure(PageConfiguration config)
 {
     lock (pagesByKey)
     {
         if (pagesByKey.ContainsKey(config.Page))
         {
             pagesByKey[config.Page] = config;
         }
         else
         {
             pagesByKey.Add(config.Page, config);
         }
     }
 }
Пример #17
0
    protected override void Initialize(RequestContext rc)
    {
        // the PageConfiguration is determined by the
        // Controller that is being called
        var pageName = rc.RouteData.Values.Values.FirstOrDefault();

        this.PageConfiguration = GetPageConfiguration(pageName.ToString());

        WrapperManager wm = GetWrapperManager(this.PageConfiguration.Id);

        ViewData["WrapperTop"]    = wm.WrapperPartOne;
        ViewData["WrapperBottom"] = wm.WrapperPartTwo;

        base.Initialize(rc);
    }
Пример #18
0
        public static ResponseModel <PageResultModel <Message> > GetMessages(PageConfiguration configuration)
        {
            //XDocument doc = XDocument.Load(HttpContext.Current.Server.MapPath("~/App_data/Messages.xml"));
            //ResponseModel<PageResultModel<Message>> response = new ResponseModel<PageResultModel<Message>>();
            //PageResultModel<Message> list = new PageResultModel<Message>();
            //if (doc != null)
            //{
            //    var modules = new Modules();
            //    modules = Deserialize<Modules>(doc.ToString());

            //    var successMessages = modules.Success.Message;
            //    var errorMessage = modules.Error.Message;
            //    foreach (var message in errorMessage)
            //    {
            //        message.Type = "Error";
            //    }
            //    foreach (var message in successMessages)
            //    {
            //        message.Type = "Success";
            //    }
            //    var query = errorMessage.Concat(successMessages).AsEnumerable();
            //    if (!string.IsNullOrEmpty(configuration.Search))
            //    {
            //        query = query
            //            .Where(m => m.Code.ToLower() == configuration.Search.ToLower()
            //            || m.message.ToLower().Contains(configuration.Search.ToLower())
            //            || m.Info.ToLower().Contains(configuration.Search.ToLower())
            //            );
            //    }
            //    var messages = query
            //        .OrderBy(m => m.Code)
            //        .Skip((configuration.PageNumber - 1) * configuration.PageSize).Take(configuration.PageSize);


            //    list.PageNumber = configuration.PageNumber;
            //    list.TotalPages = (int)Math.Ceiling((double)query.Count() / configuration.PageSize);
            //    list.Showing = messages.Count();


            //    list.Records = messages.ToList();
            //    list.TotalRecords = query.Count();
            //    response.IsSuccess = true;
            //    response.ResponseObject = list;
            //}


            return(null);
        }
Пример #19
0
        public ResponseModel <IEnumerable <MenuItemDto> > GetTopItems(long restaurantid)
        {
            ResponseModel <IEnumerable <MenuItemDto> > result = new ResponseModel <IEnumerable <MenuItemDto> >();

            try
            {
                int topItemCount = 10;
                int.TryParse(_configuration.GetSection("MyReataurantConfiguration:TopItemCount").Value, out topItemCount);
                PageConfiguration configuration = new PageConfiguration
                {
                    PageNumber = 1,
                    PageSize   = topItemCount
                };
                var menuItemRatings = _unitOfWork.Repository <Rating>()
                                      .GetAll(m => (m.MenuItemId != null || m.RestaurantId != null) && m.Rate > 3 && m.Rate < 5 && m.RestaurantId == restaurantid).Select(m => new
                {
                    RestaurantId = m.RestaurantId,
                    MenuItemId   = m.MenuItemId
                }).GroupBy(m => m.RestaurantId).Select(m => m.FirstOrDefault()).Distinct().ToList();

                List <long?> restaurantList = menuItemRatings.Select(m => m.RestaurantId).ToList();
                List <long?> menuItemList   = menuItemRatings.Select(m => m.MenuItemId).ToList();


                Func <MenuItem, bool> conditions = m => !m.IsDeleted && m.Menu.RestaurantId == restaurantid;

                if (menuItemList.Count > 0 && restaurantList.Any())
                {
                    conditions = m => !m.IsDeleted && (menuItemList.Contains(m.Id) || restaurantList.Contains(m.Menu.RestaurantId)) && m.Menu.RestaurantId == restaurantid;
                }
                if (menuItemList.Any() && !restaurantList.Any())
                {
                    conditions = m => !m.IsDeleted && (menuItemList.Contains(m.Id)) && m.Menu.RestaurantId == restaurantid;
                }
                if (restaurantList.Any() && !menuItemList.Any())
                {
                    conditions = m => !m.IsDeleted && (restaurantList.Contains(m.Menu.RestaurantId)) && m.Menu.RestaurantId == restaurantid;
                }
                result.ResponseObject = GetItems(conditions, configuration);

                result.IsSuccess = true;
            }
            catch (Exception ex)
            {
                result.IsFailed = true;
            }
            return(result);
        }
Пример #20
0
        public ResponseModel <PageResultModel <RestaurantChefDto> > GetChefs(PageConfiguration configuration)
        {
            ResponseModel <PageResultModel <RestaurantChefDto> > result = new ResponseModel <PageResultModel <RestaurantChefDto> >();
            PageResultModel <RestaurantChefDto> chefs = new PageResultModel <RestaurantChefDto>();

            try
            {
                Func <RestaurantChef, bool> expression = m => (configuration.ShowDeleted ? (m.IsDeleted || !m.IsDeleted) : !m.IsDeleted);
                string[] include        = new string[] { "Restaurant" };
                string[] excludeMapping = new string[] { "RestaurantChefs", "ChefCuisines" };
                if (!string.IsNullOrEmpty(configuration.Search))
                {
                    DateTime searchDate = new DateTime();
                    DateTime.TryParse(configuration.Search, out searchDate);
                    if (searchDate != new DateTime())
                    {
                        expression = m => (configuration.ShowDeleted ? (m.IsDeleted || !m.IsDeleted) : !m.IsDeleted) &&
                                     ((m.FirstName + " " + m.LastName).Contains(configuration.Search));
                    }
                    else
                    {
                        expression = m => (configuration.ShowDeleted ? (m.IsDeleted || !m.IsDeleted) : !m.IsDeleted) &&
                                     ((m.FirstName + " " + m.LastName).Contains(configuration.Search) || m.Restaurant.RestaurantName.Contains(configuration.Search));
                    }
                }
                var records = _unitOfWork.Repository <RestaurantChef>().GetMultiple(configuration, expression, include);
                foreach (var item in records.Records)
                {
                    RestaurantChefDto dto = new RestaurantChefDto();
                    dto = Mapper <RestaurantChef, RestaurantChefDto> .Map(item, dto, excludeMapping);

                    chefs.Records.Add(dto);
                }
                chefs.TotalPages      = records.TotalPages;
                chefs.TotalRecords    = records.TotalRecords;
                chefs.PageNumber      = records.PageNumber;
                chefs.Showing         = records.Showing;
                result.IsSuccess      = true;
                result.ResponseObject = chefs;
            }
            catch (Exception ex)
            {
                result.IsFailed  = true;
                result.ErrorCode = CommonConstants.ErrorCode.InternalServerError;
            }
            return(result);
        }
Пример #21
0
        public ResponseModel <PageResultModel <OfferDto> > GetOffers(PageConfiguration configuration)
        {
            ResponseModel <PageResultModel <OfferDto> > result = new ResponseModel <PageResultModel <OfferDto> >();
            PageResultModel <OfferDto> offers = new PageResultModel <OfferDto>();

            try
            {
                Func <Offer, bool> expression = m => (configuration.ShowDeleted ? (m.IsDeleted || !m.IsDeleted) : !m.IsDeleted);
                if (!string.IsNullOrEmpty(configuration.Search))
                {
                    DateTime searchDate = new DateTime();
                    DateTime.TryParse(configuration.Search, out searchDate);
                    if (searchDate != new DateTime())
                    {
                        expression = m => (configuration.ShowDeleted ? (m.IsDeleted || !m.IsDeleted) : !m.IsDeleted) &&
                                     (m.OfferStartDate == searchDate || m.OfferEndDate == searchDate);
                    }
                    else
                    {
                        expression = m => (configuration.ShowDeleted ? (m.IsDeleted || !m.IsDeleted) : !m.IsDeleted) &&
                                     (m.OfferName.ToLower().Contains(configuration.Search.ToLower()) &&
                                      m.OfferDescription.ToLower().Contains(configuration.Search.ToLower()));
                    }
                }
                var records = _unitOfWork.Repository <Offer>().GetMultiple(configuration, expression);
                foreach (var item in records.Records)
                {
                    OfferDto dto = new OfferDto();
                    dto = Mapper <Offer, OfferDto> .Map(item, dto);

                    offers.Records.Add(dto);
                }
                offers.TotalPages     = records.TotalPages;
                offers.TotalRecords   = records.TotalRecords;
                offers.PageNumber     = records.PageNumber;
                offers.Showing        = records.Showing;
                result.IsSuccess      = true;
                result.ResponseObject = offers;
            }
            catch (Exception ex)
            {
                result.IsFailed  = true;
                result.ErrorCode = CommonConstants.ErrorCode.InternalServerError;
            }
            return(result);
        }
Пример #22
0
        public PageResultModel <T> GetMultiple(PageConfiguration configuration, Func <T, bool> predicate, string[] include)
        {
            IQueryable <T> query = table.AsNoTracking().AsQueryable();

            foreach (var inc in include)
            {
                query = query.Include(inc);
            }
            var entity = query.Where(predicate);
            PageResultModel <T> result = new PageResultModel <T>();

            result.TotalRecords = entity.Count();
            result.PageNumber   = configuration.PageNumber;
            result.TotalPages   = (int)Math.Ceiling((double)entity.Count() / configuration.PageSize);
            result.Records      = entity.Skip((configuration.PageNumber - 1) * configuration.PageSize).Take(configuration.PageSize).ToList();
            result.Showing      = result.Records.Count();
            return(result);
        }
Пример #23
0
        public void CreatePage(PageNumber pageNumber, PageConfiguration configuration)
        {
            if (_pages.ContainsKey(pageNumber))
            {
                return;
            }

            var pdfPage = new PdfPage
            {
                Orientation = (PdfSharp.PageOrientation)configuration.PageOrientation
            };

            pdfPage.Width  = configuration.Size.Width;
            pdfPage.Height = configuration.Size.Height;

            _pdfDocument.AddPage(pdfPage);
            _pages.Add(pageNumber, new PdfRendererPage(pageNumber, XGraphics.FromPdfPage(pdfPage), this.Options));
        }
Пример #24
0
        public ResponseModel <List <MenuDto> > GetRestaurantMenus(long restaurantid)
        {
            ResponseModel <List <MenuDto> > response = new ResponseModel <List <MenuDto> >();

            try
            {
                string[] include        = new string[] { "MenuItems", "Cuisine", "MenuCategory" };
                string[] excludeMapping = new string[] { "Restaurant", "MenuItems", "MenuCategory", "Cuisine", "Menus", "Menu" };
                int      pageSize       = 10;
                int.TryParse(_configuration.GetSection("MyReataurantConfiguration:TopItemCount").Value, out pageSize);
                PageConfiguration configuration = new PageConfiguration()
                {
                    PageNumber = 1,
                    PageSize   = pageSize
                };
                var            entity  = _unitOfWork.Repository <Menu>().GetMultiple(configuration, m => m.RestaurantId == restaurantid && !m.IsDeleted, include).Records;
                List <MenuDto> dtoList = new List <MenuDto>();
                foreach (var menu in entity)
                {
                    var dto = Mapper <Menu, MenuDto> .Map(menu, new MenuDto(), excludeMapping);

                    dto.MenuCategory = Mapper <MenuCategory, MenuCategoryDto> .Map(menu.MenuCategory, new MenuCategoryDto(), excludeMapping);

                    dto.MenuItems     = new List <MenuItemDto>();
                    dto.Cuisine       = menu.Cuisine;
                    dto.Cuisine.Menus = null;
                    foreach (var item in menu.MenuItems)
                    {
                        var itemDto = Mapper <MenuItem, MenuItemDto> .Map(item, new MenuItemDto(), excludeMapping);

                        dto.MenuItems.Add(itemDto);
                    }
                    dtoList.Add(dto);
                }
                response.ResponseObject = dtoList;
                response.IsSuccess      = true;
            }
            catch (Exception ex)
            {
                response.IsFailed  = true;
                response.ErrorCode = CommonConstants.ErrorCode.InternalServerError;
            }
            return(response);
        }
Пример #25
0
        private static IEnumerable <ColumnConfig> GetSectionColumnConfigs(
            this Word.SectionProperties wordSectionProperties,
            PageConfiguration page,
            PageMargin pageMargin)
        {
            var columns = wordSectionProperties
                          .ChildsOfType <Word.Columns>()
                          .SingleOrDefault();

            var totalColumnsWidth = page.Width - pageMargin.HorizontalMargins;
            var columnsCount      = columns.ColumnCount?.Value ?? 1;

            if (columnsCount == 1)
            {
                return(new[] { new ColumnConfig(totalColumnsWidth, 0) });
            }

            if (columns.EqualWidth.IsOn(true))
            {
                var space       = columns.Space.ToPoint();
                var columnWidth = (totalColumnsWidth - space * (columnsCount - 1)) / columnsCount;

                return(Enumerable.Range(0, columnsCount)
                       .Select(i =>
                {
                    var s = i == columnsCount - 1
                            ? 0
                            : space;
                    return new ColumnConfig(columnWidth, s);
                })
                       .ToArray());
            }

            var cols = columns
                       .ChildsOfType <Word.Column>()
                       .Select(col =>
            {
                var cw    = col.Width.ToPoint();
                var space = col.Space.ToPoint();
                return(new ColumnConfig(cw, space));
            });

            return(cols);
        }
Пример #26
0
        public ResponseModel <IEnumerable <RestaurantDto> > TopRatedRestaurants()
        {
            ResponseModel <IEnumerable <RestaurantDto> > result = new ResponseModel <IEnumerable <RestaurantDto> >();

            try
            {
                int itemCount = 10;
                int.TryParse(_configuration.GetSection("MyReataurantConfiguration:TopItemCount").Value, out itemCount);
                PageConfiguration configuration = new PageConfiguration
                {
                    PageNumber = 1,
                    PageSize   = itemCount
                };
                var restaurantRatings = _unitOfWork.Repository <Rating>()
                                        .GetAll(m => m.RestaurantId != null && m.Rate > 3 && m.Rate < 5)
                                        .OrderBy(m => m.Rate).Select(m => m.RestaurantId).ToList();
                Func <Restaurant, bool> expression = m => !m.IsDeleted;

                IEnumerable <RestaurantDto> restaurants;
                if (_unitOfWork.Repository <Restaurant>().Any(m => restaurantRatings.Contains(m.Id)))
                {
                    expression = m => !m.IsDeleted && restaurantRatings.Contains(m.Id);
                }
                restaurants = _unitOfWork.Repository <Restaurant>()
                              .GetMultiple(configuration, expression)
                              .Records.Select(m => new RestaurantDto
                {
                    Id             = m.Id,
                    Logo           = m.Logo,
                    RestaurantCode = m.RestaurantCode,
                    RestaurantName = m.RestaurantName
                }).ToList();
                result.IsSuccess      = true;
                result.ResponseObject = restaurants;
            }
            catch (Exception ex)
            {
                result.IsFailed  = true;
                result.ErrorCode = CommonConstants.ErrorCode.InternalServerError;
            }
            return(result);
        }
Пример #27
0
        public static PageConfiguration GetA4Page()
        {
            // ((X mm) / (25.4mm/in)) x (Y pixels/in)
            var horizontal = (210 / 25.4) * 96;
            var vertical   = (297 / 25.4) * 96;
            var originH    = (10 / 25.4) * 96;
            var originV    = originH;

            PageConfiguration pageConfiguration = new PageConfiguration
            {
                OriginWidth  = originH,
                OriginHeight = originV,
                ExtentWidth  = horizontal - 2 * originH,
                ExtentHeight = vertical - 2 * originV,
                PageWidth    = horizontal,
                PageHeight   = vertical
            };

            return(pageConfiguration);
        }
Пример #28
0
        public ResponseModel <PageResultModel <PageDto> > Navigations(PageConfiguration configuration)
        {
            ResponseModel <PageResultModel <PageDto> > response = new ResponseModel <PageResultModel <PageDto> >();
            PageResultModel <PageDto> navigationRecords         = new PageResultModel <PageDto>();

            try
            {
                response.IsSuccess = true;
                Func <Page, bool> expression = m => (configuration.ShowDeleted ? (m.IsDeleted || !m.IsDeleted) : !m.IsDeleted);
                if (!string.IsNullOrEmpty(configuration.Search))
                {
                    expression = m => (configuration.ShowDeleted ? (m.IsDeleted || !m.IsDeleted) : !m.IsDeleted) &&
                                 (m.Name.ToLower().Contains(configuration.Search.ToLower()) ||
                                  m.Url.ToLower().Contains(configuration.Search.ToLower()) ||
                                  m.ControllerName.ToLower().Contains(configuration.Search.ToLower()) ||
                                  m.ActionName.ToLower().Contains(configuration.Search.ToLower())
                                 );
                }
                var records = _unitOfWork.Repository <Page>().GetMultiple(configuration, expression);
                foreach (var item in records.Records)
                {
                    PageDto dto = new PageDto();
                    dto = Mapper <Page, PageDto> .Map(item, dto);

                    navigationRecords.Records.Add(dto);
                }
                navigationRecords.TotalPages   = records.TotalPages;
                navigationRecords.TotalRecords = records.TotalRecords;
                navigationRecords.PageNumber   = records.PageNumber;
                navigationRecords.Showing      = records.Showing;
                response.ResponseObject        = navigationRecords;
            }
            catch (Exception ex)
            {
                response.IsFailed  = true;
                response.ErrorCode = CommonConstants.ErrorCode.InternalServerError;
            }
            return(response);
        }
Пример #29
0
        public ResponseModel <List <RestaurantChefDto> > GetRestaurantChefUI(long restaurantId)
        {
            ResponseModel <List <RestaurantChefDto> > result = new ResponseModel <List <RestaurantChefDto> >();
            PageConfiguration configuration = new PageConfiguration()
            {
                PageNumber = 1,
                PageSize   = 4
            };

            string[] include        = new string[] { "ChefCuisines.Cuisine" };
            string[] excludeMapping = new string[] { "RestaurantChef", "ChefCuisines" };
            try
            {
                var entity = _unitOfWork.Repository <RestaurantChef>().GetMultiple(configuration, m => m.RestaurantId == restaurantId &&
                                                                                   !m.IsDeleted && (m.ChefRating >= 3 && m.ChefRating <= 5), include).Records;
                List <RestaurantChefDto> records = new List <RestaurantChefDto>();
                foreach (var chef in entity)
                {
                    var dto = Mapper <RestaurantChef, RestaurantChefDto> .Map(chef, new RestaurantChefDto(), excludeMapping);

                    dto.ChefCuisines = chef.ChefCuisines.Where(m => !m.IsDeleted).Select(m => new ChefCuisineDto {
                        Id               = m.Id,
                        Cuisine          = m.Cuisine,
                        RestaurantChefId = m.RestaurantChefId
                    }).ToList();
                    records.Add(dto);
                }
                result.ResponseObject = records;
                result.IsSuccess      = true;
            }
            catch (Exception ex)
            {
                result.IsFailed  = true;
                result.ErrorCode = CommonConstants.ErrorCode.InternalServerError;
            }
            return(result);
        }
Пример #30
0
        public ResponseModel <PageResultModel <RestaurantDto> > List(PageConfiguration configuration)
        {
            ResponseModel <PageResultModel <RestaurantDto> > response = new ResponseModel <PageResultModel <RestaurantDto> >();
            PageResultModel <RestaurantDto> menuRecords = new PageResultModel <RestaurantDto>();

            menuRecords.Records = new List <RestaurantDto>();
            try
            {
                Func <Restaurant, bool> expression = m => m.AspNetUserId == configuration.UserId && (configuration.ShowDeleted ? (m.IsDeleted || !m.IsDeleted) : !m.IsDeleted);
                if (!string.IsNullOrEmpty(configuration.Search))
                {
                    expression = m => (configuration.ShowDeleted ? (m.IsDeleted || !m.IsDeleted) : !m.IsDeleted) && (m.RestaurantName.ToLower().Contains(configuration.Search.ToLower()) &&
                                                                                                                     m.AspNetUserId == configuration.UserId);
                }
                var records = _unitOfWork.Repository <Restaurant>().GetMultiple(configuration, expression);
                foreach (var item in records.Records)
                {
                    RestaurantDto dto = new RestaurantDto();
                    dto = Mapper <Restaurant, RestaurantDto> .Map(item, dto);

                    menuRecords.Records.Add(dto);
                }
                menuRecords.TotalPages   = records.TotalPages;
                menuRecords.TotalRecords = records.TotalRecords;
                menuRecords.PageNumber   = records.PageNumber;
                menuRecords.Showing      = records.Showing;
                response.IsSuccess       = true;
                response.ResponseObject  = menuRecords;
            }
            catch (Exception ex)
            {
                response.IsFailed  = true;
                response.ErrorCode = CommonConstants.ErrorCode.InternalServerError;
            }

            return(response);
        }