Exemplo n.º 1
0
        private List <ShippingCompanyDTO> GetShippingCompanies(Langs l, Currency currency)
        {
            List <ShippingCompanyDTO> ShippingCompanyDTOs = new List <ShippingCompanyDTO>();
            var companies = unitOfWork.ShippingCompanyRepository.Get(c => c.IsActive == true).ToList();

            foreach (var company in companies)
            {
                ShippingCompanyDTO shippingCompanyDTO = new ShippingCompanyDTO();
                shippingCompanyDTO.Id               = company.Id;
                shippingCompanyDTO.ShippingCost     = Utils.getCurrency(currency, l, company.ShippingCost).Item1;
                shippingCompanyDTO.ShippingCurrency = Utils.getCurrency(currency, l, company.ShippingCost).Item2;
                long lang = Utils.getLanguage(l);

                ShippingCompanyDescription desc = unitOfWork.ShippingCompanyDescriptionRepository.Get(c =>
                                                                                                      c.LanguageId == lang &&
                                                                                                      c.ShippingCompanyId == company.Id).FirstOrDefault();

                shippingCompanyDTO.Name            = desc.Name;
                shippingCompanyDTO.MetaDescription = desc.MetaDescription;

                ShippingCompanyDTOs.Add(shippingCompanyDTO);
            }
            return(ShippingCompanyDTOs);
        }
Exemplo n.º 2
0
        public OrderDTO GetOrderById(long id, Langs l, Currency c)
        {
            OrderDTO orderDTO = new OrderDTO();
            Order    order    = unitOfWork.OrderRepository.GetByID(id);

            orderDTO.BillingAddress  = GetOrderAddress(order.BillingAddress);
            orderDTO.ShippingAddress = GetOrderAddress(order.ShippingAddress);
            orderDTO.OrderItems      = GetOrderItems(order.Id, l, c);
            orderDTO.CurrencyName    = Utils.getCurrencyName(c, l);
            orderDTO.InvoiceId       = order.InvoiceId;
            orderDTO.ClosingDate     = order.ClosingDate;
            orderDTO.UserIpAddress   = order.UserIpAddress;
            orderDTO.UserAgent       = order.UserAgent;
            if (!String.IsNullOrEmpty(order.CouponCode))
            {
                orderDTO.CouponCode     = order.CouponCode;
                orderDTO.CouponValue    = order.CouponValue;
                orderDTO.CouponCurrency = orderDTO.CurrencyName;
                if (!order.CouponIsPercentage)
                {
                    orderDTO.CouponValue    = Utils.getCurrency(c, l, order.CouponValue).Item1;
                    orderDTO.CouponCurrency = "-";
                }
                else
                {
                    orderDTO.CouponCurrency = "%";
                }
            }

            // get Order Owner
            var user = _userService.getuserById(order.UserId);

            orderDTO.CreationDate       = order.CreationDate.Value;
            orderDTO.DateModified       = order.DateModified;
            orderDTO.Discount           = order.Discount;
            orderDTO.Id                 = order.Id;
            orderDTO.InvoiceId          = order.InvoiceId;
            orderDTO.PaymentDate        = order.PaymentDate;
            orderDTO.PaymentNotes       = order.PaymentNotes;
            orderDTO.PaymentDate        = order.PaymentDate;
            orderDTO.ShippingCost       = order.ShippingCost;
            orderDTO.Status             = order.Status;
            orderDTO.SubTotal           = Utils.getCurrency(c, l, order.SubTotal).Item1;
            orderDTO.Total              = Utils.getCurrency(c, l, order.Total).Item1;
            orderDTO.TransactionDetails = order.TransactionDetails;
            orderDTO.TransactionId      = order.TransactionId;
            orderDTO.UserId             = order.UserId;
            orderDTO.Phone              = order.ShippingAddress.Phone;
            orderDTO.UserName           = user.FirstName + " " + user.LastName;
            orderDTO.Email              = user.Email;
            orderDTO.OrderHistories     = GetOrderHistory(id);


            ShippingMethodDTO  shippingMethodDTO  = new ShippingMethodDTO();
            BillingMethodDTO   billingMethodDTO   = new BillingMethodDTO();
            ShippingCompanyDTO shippingCompanyDTO = new ShippingCompanyDTO();

            if (l == Langs.English)
            {
                shippingMethodDTO.Name  = order.EnglishShippingName;
                billingMethodDTO.Name   = order.EnglishBillingName;
                shippingCompanyDTO.Name = order.EnglishCompanyName;
            }
            else
            {
                shippingMethodDTO.Name  = order.ArabicShippingName;
                billingMethodDTO.Name   = order.ArabicBillingName;
                shippingCompanyDTO.Name = order.ArabicCompanyName;
            }

            orderDTO.ShippingMethod = shippingMethodDTO;
            orderDTO.BillingMethod  = billingMethodDTO;
            return(orderDTO);
        }