public ActionResult AllCustomers()
        {
            List <CustomerView> customers = new List <CustomerView>();

            foreach (var customer in _sharingService.GetAllCustomers())
            {
                customers.Add(new CustomerView
                {
                    Id        = customer.Id,
                    Email     = customer.Email,
                    FirstName = customer.FirstName,
                    Surname   = customer.Surname
                });
            }

            PagingInfoView pagingInfo = new PagingInfoView
            {
                CurrentPage  = 1,
                ItemsPerPage = PagerParameters.PageSize,
                TotalItems   = customers.Count
            };

            CustomersView customersView = new CustomersView
            {
                Customers  = customers,
                PagingInfo = pagingInfo
            };

            return(View(customersView));
        }
        public ActionResult OpenedRents(ParametersView parameters)
        {
            ParametersBll parametersBll = new ParametersBll()
            {
                PriceFilter = parameters.PriceFilter,
                TypeFilter  = parameters.TypeFilter,
                Page        = parameters.Page,
                PageSize    = PagerParameters.PageSize
            };
            List <OfferView> offers    = new List <OfferView>();
            List <OfferBll>  offersBll = _sharingService.GetSelectedTypes(parametersBll);

            _sharingService.Sort(parametersBll, offersBll);
            offersBll = offersBll.Where(offer => _sharingService.IsOfferTaken(offer.Id)).ToList();
            offersBll = _sharingService.GetCurrentPageItems(offersBll, parametersBll);

            foreach (var offer in offersBll)
            {
                bool isTaken = _sharingService.IsOfferTaken(offer.Id);
                offers.Add(new OfferView
                {
                    Id          = offer.Id,
                    Model       = offer.Model,
                    Description = offer.Description,
                    Year        = offer.Year,
                    Image       = offer.Image,
                    Type        = offer.Type,
                    DailyCost   = offer.DailyCost,
                    IsTaken     = isTaken
                });
            }

            List <OfferView> takenOffers = new List <OfferView>();

            foreach (OfferView offer in offers)
            {
                if (offer.IsTaken)
                {
                    takenOffers.Add(offer);
                }
            }

            int totalItems = takenOffers.Count;

            PagingInfoView pagingInfo = new PagingInfoView
            {
                CurrentPage  = parameters.Page,
                ItemsPerPage = PagerParameters.PageSize,
                TotalItems   = totalItems
            };

            OffersView offerView = new OffersView()
            {
                Offers     = takenOffers,
                PagingInfo = pagingInfo
            };

            return(View(offerView));
        }
Beispiel #3
0
        public static MvcHtmlString PageLinksUsingSubmitForm(
            this HtmlHelper html,
            PagingInfoView pagingInfo,
            string functionName
            )
        {
            StringBuilder result = new StringBuilder();



            for (int i = 1; i <= pagingInfo.TotalPages(); i++)
            {
                if (pagingInfo.CurrentPage != 1 && i == 1)
                {
                    TagBuilder arrowTag = new TagBuilder("a");//todo or not
                    TagBuilder arrowDiv = new TagBuilder("div");
                    arrowDiv.AddCssClass("btn btn-default");
                    arrowTag.MergeAttribute("href", "javascript: PageClick(" + i + ")");
                    arrowDiv.InnerHtml = "<";

                    arrowTag.InnerHtml += arrowDiv.ToString(TagRenderMode.Normal);
                    result.Append(arrowTag);
                }

                TagBuilder div = new TagBuilder("div");
                div.AddCssClass("btn btn-default");

                TagBuilder tag = new TagBuilder("a");
                tag.MergeAttribute("href", "javascript: PageClick(" + i + ")");

                div.InnerHtml = i.ToString();
                if (i == pagingInfo.CurrentPage)
                {
                    div.AddCssClass("selected");
                }

                tag.InnerHtml += div.ToString(TagRenderMode.Normal);
                result.Append(tag);


                if (pagingInfo.CurrentPage != pagingInfo.TotalPages() && i == pagingInfo.TotalPages())
                {
                    TagBuilder arrowTag = new TagBuilder("a");//todo or not
                    TagBuilder arrowDiv = new TagBuilder("div");
                    arrowDiv.AddCssClass("btn btn-default");
                    arrowTag.MergeAttribute("href", "javascript: PageClick(" + i + ")");
                    arrowDiv.InnerHtml = ">";

                    arrowTag.InnerHtml += arrowDiv.ToString(TagRenderMode.Normal);
                    result.Append(arrowTag);
                }
            }
            return(MvcHtmlString.Create(result.ToString()));
        }
        public ActionResult OpenedRents()
        {
            ParametersBll parametersBll = new ParametersBll
            {
                Page     = 1,
                PageSize = PagerParameters.PageSize
            };

            List <OfferView> offers = new List <OfferView>();

            foreach (var offer in _sharingService.GetTakenOffers(parametersBll))
            {
                const bool isTaken = true;

                offers.Add(new OfferView
                {
                    Id          = offer.Id,
                    Model       = offer.Model,
                    Description = offer.Description,
                    Year        = offer.Year,
                    Image       = offer.Image,
                    Type        = offer.Type,
                    DailyCost   = offer.DailyCost,
                    IsTaken     = isTaken
                });
            }

            int totalItems = offers.Count;

            PagingInfoView pagingInfo = new PagingInfoView
            {
                CurrentPage  = 1,
                ItemsPerPage = PagerParameters.PageSize,
                TotalItems   = totalItems
            };

            OffersView offersView = new OffersView()
            {
                Offers     = offers,
                PagingInfo = pagingInfo
            };

            return(View(offersView));
        }
        public ActionResult AllCustomers(ParametersView parameters)
        {
            ParametersBll parametersBll = new ParametersBll
            {
                Page     = parameters.Page,
                PageSize = PagerParameters.PageSize
            };


            List <CustomerBll> customersBll = _sharingService.GetAllCustomers();
            int totalItems = customersBll.Count;

            customersBll = _sharingService.GetCurrentPageCustomers(customersBll, parametersBll);

            List <CustomerView> customersView = new List <CustomerView>();

            foreach (var customer in customersBll)
            {
                customersView.Add(new CustomerView
                {
                    Id        = customer.Id,
                    Email     = customer.Email,
                    FirstName = customer.FirstName,
                    Surname   = customer.Surname
                });
            }

            PagingInfoView pagingInfo = new PagingInfoView
            {
                CurrentPage  = parameters.Page,
                ItemsPerPage = PagerParameters.PageSize,
                TotalItems   = totalItems
            };

            CustomersView customers = new CustomersView
            {
                Customers  = customersView,
                PagingInfo = pagingInfo
            };

            return(View(customers));
        }
Beispiel #6
0
        public static MvcHtmlString PageLinks(
            this HtmlHelper html,
            PagingInfoView pagingInfo,
            Func <int, string> pageUrl)
        {
            StringBuilder result = new StringBuilder();

            for (int i = 1; i <= pagingInfo.TotalPages(); i++)
            {
                TagBuilder tag = new TagBuilder("a"); // Construct an <a> tag
                tag.MergeAttribute("href", pageUrl(i));
                tag.InnerHtml = i.ToString();
                if (i == pagingInfo.CurrentPage)
                {
                    tag.AddCssClass("selected");
                }
                result.Append(tag.ToString());
            }
            return(MvcHtmlString.Create(result.ToString()));
        }
Beispiel #7
0
        public static MvcHtmlString PageLinksUsingSubmitForm(
            this HtmlHelper html,
            PagingInfoView pagingInfo,
            string functionName)
        {
            StringBuilder result = new StringBuilder();

            for (int i = 1; i <= pagingInfo.TotalPages(); i++)
            {
                TagBuilder tag = new TagBuilder("a"); // Construct an <a> tag
                tag.MergeAttribute("href", "javascript: PagerClick(" + i + ")");
                tag.InnerHtml = i.ToString();
                if (i == pagingInfo.CurrentPage)
                {
                    tag.AddCssClass("selected");
                }
                result.Append(tag.ToString());
            }
            return(MvcHtmlString.Create(result.ToString()));
        }
Beispiel #8
0
        public ActionResult Circles(ParametrsForView parametrs)//+
        {
            try
            {
                List <CirlceView>   cirlces = new List <CirlceView>();
                ParametrsForViewBll pBll    = new ParametrsForViewBll()
                {
                    Page       = parametrs.Page,
                    PageSize   = Parametrs.PageSize,
                    PartOfName = parametrs.PartOfName ?? ""
                };
                int  totalItems   = _figuresService.GetCirclesCount(pBll);
                bool isPAgeActual = ((parametrs.Page - 1) * Parametrs.PageSize < totalItems);
                int  updatedPage  = isPAgeActual ? parametrs.Page : 1;
                pBll.Page = updatedPage;
                foreach (var item in _figuresService.GetAllCirlces(pBll))
                {
                    cirlces.Add(new CirlceView()
                    {
                        Id = item.Id, Name = item.Name, Radius = item.Radius
                    });
                }

                PagingInfoView pagingInfo = new PagingInfoView
                {
                    CurrentPage  = pBll.Page,
                    ItemsPerPage = Parametrs.PageSize,
                    TotalItems   = totalItems
                };
                CirlcesView c = new CirlcesView()
                {
                    Cirlces    = cirlces,
                    PagingInfo = pagingInfo,
                };
                return(View(c));
            }
            catch (Exception ex)
            {
                return(HttpNotFound(ex.Message));
            }
        }
Beispiel #9
0
        public ActionResult Circles()//+
        {
            try
            {
                ParametrsForView  p       = new ParametrsForView();
                List <CirlceView> cirlces = new List <CirlceView>();

                ParametrsForViewBll pBll = new ParametrsForViewBll()
                {
                    Page       = p.Page,
                    PageSize   = Parametrs.PageSize,
                    PartOfName = p.PartOfName
                };
                foreach (var item in _figuresService.GetAllCirlces(pBll))
                {
                    cirlces.Add(new CirlceView()
                    {
                        Id = item.Id, Name = item.Name, Radius = item.Radius
                    });
                }
                PagingInfoView pagingInfo = new PagingInfoView
                {
                    CurrentPage  = p.Page,
                    ItemsPerPage = Parametrs.PageSize,
                    TotalItems   = _figuresService.GetCirclesCount(pBll)
                };
                CirlcesView c = new CirlcesView()
                {
                    Cirlces    = cirlces,
                    PagingInfo = pagingInfo,
                };
                return(View(c));
            }
            catch (Exception ex)
            {
                return(HttpNotFound(ex.Message));
            }
        }
Beispiel #10
0
        public ActionResult Squares(int page = 1)
        {
            try
            {
                List <SquareView>   squares = new List <SquareView>();
                ParametrsForViewBll pBll    = new ParametrsForViewBll()
                {
                    Page     = page,
                    PageSize = Parametrs.PageSize,
                };
                foreach (var item in _figuresService.GetAllSquares(pBll))
                {
                    squares.Add(new SquareView()
                    {
                        Id = item.Id, Name = item.Name, Side = item.Side
                    });
                }

                PagingInfoView pagingInfo = new PagingInfoView
                {
                    CurrentPage  = page,
                    ItemsPerPage = Parametrs.PageSize,
                    TotalItems   = _figuresService.GetSquaresCount(pBll)
                };
                SquaresView c = new SquaresView()
                {
                    Squares    = squares,
                    PagingInfo = pagingInfo,
                };

                return(View(c));
            }
            catch (Exception ex)
            {
                return(HttpNotFound(ex.Message));
            }
        }
        public ActionResult CustomerDetails(ParametersView parameters)
        {
            ParametersBll parametersBll = new ParametersBll
            {
                PageSize = PagerParameters.PageSize,
                Page     = parameters.Page
            };

            CustomerBll customerBll = _sharingService.GetCustomerById(parameters.CustomerId);

            CustomerDetailsView customerDetails = new CustomerDetailsView
            {
                Id        = customerBll.Id,
                FirstName = customerBll.FirstName,
                Surname   = customerBll.Surname,
                Email     = customerBll.Email
            };

            foreach (RentBll rent in _sharingService.GetRentsByEmail(customerBll.Email))
            {
                customerDetails.Rents.Add(new RentView
                {
                    OfferId       = rent.OfferBll.Id,
                    Cost          = rent.Cost,
                    Customer      = customerBll,
                    StartDate     = rent.StartDate,
                    EndDate       = rent.EndDate,
                    InsuranceCase = rent.InsuranceCase
                });
            }

            foreach (var rent in customerDetails.Rents)
            {
                OfferBll  offerBll  = _sharingService.GetOfferById(rent.OfferId);
                OfferView offerView = new OfferView
                {
                    Id          = offerBll.Id,
                    Model       = offerBll.Model,
                    Description = offerBll.Description,
                    Year        = offerBll.Year,
                    Image       = offerBll.Image,
                    Type        = offerBll.Type,
                    DailyCost   = offerBll.DailyCost,
                    IsTaken     = _sharingService.IsOfferTaken(offerBll.Id)
                };

                customerDetails.Offers.Add(offerView);
            }

            int            totalItems = customerDetails.Offers.Count;
            PagingInfoView pagingInfo = new PagingInfoView
            {
                CurrentPage  = parameters.Page,
                ItemsPerPage = PagerParameters.PageSize,
                TotalItems   = totalItems
            };

            if (customerDetails.Offers.Skip((parameters.Page - 1) * PagerParameters.PageSize).Count() > PagerParameters.PageSize)
            {
                customerDetails.Offers = customerDetails.Offers.GetRange((parameters.Page - 1) * PagerParameters.PageSize, PagerParameters.PageSize);
                customerDetails.Rents  = customerDetails.Rents.GetRange((parameters.Page - 1) * PagerParameters.PageSize, PagerParameters.PageSize);
            }
            else
            {
                customerDetails.Offers =
                    customerDetails.Offers.Skip((parameters.Page - 1) * PagerParameters.PageSize).ToList();
                customerDetails.Rents =
                    customerDetails.Rents.Skip((parameters.Page - 1) * PagerParameters.PageSize).ToList();
            }

            customerDetails.PagingInfo = pagingInfo;

            return(View(customerDetails));
        }