Пример #1
0
 public IActionResult GetOrderListForSeller()
 {
     try
     {
         var userid = ClaimPrincipalFactory.GetUserId(User);
         var seller = _repository.Seller.FindByCondition(c => c.UserId == userid).FirstOrDefault();
         if (seller == null)
         {
             return(Unauthorized());
         }
         var res = _repository.CustomerOrderProduct
                   .FindByCondition(c => c.Ddate == null && c.DaDate == null && c.SellerId == seller.Id && (c.FinalStatusId == 22 || c.FinalStatusId == 23))
                   .Include(c => c.CustomerOrder)
                   .Include(c => c.FinalStatus)
                   .Select(c => new
         {
             c.Id,
             c.ProductName,
             c.Product.Coding,
             c.OrderCount,
             c.CustomerOrder.OrderNo,
             c.FinalStatusId,
             Status    = c.FinalStatus.Name,
             Orderdate = DateTimeFunc.TimeTickToShamsi(c.CustomerOrder.OrderDate.Value)
         }).OrderByDescending(c => c.Id).ToList();
         _logger.LogData(MethodBase.GetCurrentMethod(), res, null);
         return(Ok(res));
     }
     catch (Exception e)
     {
         _logger.LogError(e, MethodBase.GetCurrentMethod());
         return(BadRequest(e.Message));
     }
 }
Пример #2
0
 public IActionResult GetOrderList()
 {
     try
     {
         var res = _repository.CustomerOrder.FindByCondition(c => c.Ddate == null && c.DaDate == null)
                   .Include(c => c.Customer)
                   .Include(c => c.FinalStatus)
                   .Include(c => c.CustomerOrderProduct)
                   .Include(c => c.CustomerOrderPayment).ThenInclude(c => c.FinalStatus)
                   .Select(c => new
         {
             c.Id,
             OrderDate = DateTimeFunc.TimeTickToShamsi(c.OrderDate.Value),
             c.OrderNo,
             OrderType    = c.OrderType == 1 ? "خرید" : "سفارش",
             CustomerName = c.Customer.Name + " " + c.Customer.Fname,
             c.FinalPrice,
             Status        = c.FinalStatus.Name,
             PaymentStatus = c.CustomerOrderPayment.OrderByDescending(u => u.Id).Select(x => x.FinalStatus.Name).FirstOrDefault(),
             Editable      = c.CustomerOrderProduct.All(x => x.FinalStatusId == 23)
         }).OrderByDescending(c => c.Id).ToList();
         _logger.LogData(MethodBase.GetCurrentMethod(), res, null);
         return(Ok(res));
     }
     catch (Exception e)
     {
         _logger.LogError(e, MethodBase.GetCurrentMethod());
         return(BadRequest(e.Message));
     }
 }
Пример #3
0
        public IActionResult GetOrderFullInfoById(long orderId)
        {
            try
            {
                var orderproduct = _repository.CustomerOrderProduct.FindByCondition(c => c.CustomerOrderId == orderId)
                                   .Include(c => c.Product)
                                   .Include(c => c.Seller)
                                   .Include(c => c.FinalStatus)
                                   .Include(c => c.PackingType)
                                   .Select(c => new
                {
                    c.Id,
                    ProductName = c.Product.Name,
                    c.ProductCode,
                    c.ProductPrice,
                    PackingType = c.PackingType.Name,
                    c.OrderCount,
                    Status = c.FinalStatus.Name,
                    Seller = c.Seller.Name + " " + c.Seller.Fname,
                }).ToList();

                var order = _repository.CustomerOrder.FindByCondition(c => c.Ddate == null && c.DaDate == null && c.Id == orderId)
                            .Include(c => c.Customer)
                            .Include(c => c.FinalStatus)
                            .Include(c => c.CustomerAddress).ThenInclude(c => c.Province)
                            .Include(c => c.CustomerAddress).ThenInclude(c => c.City)
                            .Include(c => c.CustomerOrderPayment).ThenInclude(c => c.FinalStatus)
                            .Select(c => new
                {
                    OrderDate = DateTimeFunc.TimeTickToShamsi(c.OrderDate.Value),
                    c.OrderNo,
                    OrderType    = c.OrderType == 1 ? "خرید" : "سفارش",
                    CustomerName = c.Customer.Name + " " + c.Customer.Fname,
                    c.Customer.Mobile,
                    c.FinalPrice,
                    c.FinalWeight,
                    c.PackingWeight,
                    Status        = c.FinalStatus.Name,
                    PaymentStatus = c.CustomerOrderPayment.OrderByDescending(x => x.Id)
                                    .Select(x => x.FinalStatus.Name).FirstOrDefault(),
                    Address = c.CustomerAddress.Province.Name + " - " + c.CustomerAddress.City.Name + " - " +
                              c.CustomerAddress.Address
                }).FirstOrDefault();
                var result = new { Order = order, Orderproduct = orderproduct };
                _logger.LogData(MethodBase.GetCurrentMethod(), result, null, orderId);
                return(Ok(result));
            }
            catch (Exception e)
            {
                _logger.LogError(e, MethodBase.GetCurrentMethod(), orderId);
                return(BadRequest(e.Message));
            }
        }
Пример #4
0
        public MappingProfile()
        {
            CreateMap <UserRegistrationModel, User>()
            .ForMember(u => u.UserName, opt => opt.MapFrom(x => x.Email));

            CreateMap <ProductImage, ProductImageDto>()
            .ForMember(u => u.ProductImageId, opt => opt.MapFrom(x => x.Id));
            CreateMap <Product, ProductDto>()
            .ForMember(u => u.CatProductName, opt => opt.MapFrom(x => x.CatProduct.Name));
            CreateMap <Product, ProductByOfferRate>()
            .ForMember(u => u.CatProductName, opt => opt.MapFrom(x => x.CatProduct.Name))
            .ForMember(u => u.Rate, opt => opt.MapFrom(x => x.ProductCustomerRate.Average(r => r.Rate)))
            .ForMember(u => u.OfferValue, opt => opt.MapFrom(x => x.ProductOffer.FirstOrDefault(c => (c.FromDate <= DateTime.Now.Ticks) && (DateTime.Now.Ticks <= c.ToDate)).Value))
            .ForMember(u => u.PriceAfterOffer, opt => opt.MapFrom(x => x.Price - (x.ProductOffer.Where(c => (c.FromDate <= DateTime.Now.Ticks) && (DateTime.Now.Ticks <= c.ToDate)).Select(c => c.Value).DefaultIfEmpty(0).FirstOrDefault() / 100) * x.Price));

            CreateMap <CustomerOrder, CustomerOrderListDto>()
            .ForMember(u => u.OrderPrice, opt => opt.MapFrom(x => x.FinalPrice))
            .ForMember(u => u.OrderDate, opt => opt.MapFrom(x => DateTimeFunc.TimeTickToShamsi(x.OrderDate.Value)))
            .ForMember(u => u.ProductCount, opt => opt.MapFrom(x => x.CustomerOrderProduct.Count))
            .ForMember(u => u.PaymentStatus,
                       opt => opt.MapFrom(x =>
                                          x.CustomerOrderPayment.OrderByDescending(c => c.TransactionDate).Select(c => c.FinalStatusId)
                                          .DefaultIfEmpty(0).FirstOrDefault() == 100
                            ? "پرداخت موفق"
                            : "پرداخت ناموفق"));


            CreateMap <CustomerOrderProduct, CustomerOrderProductDto>()
            .ForMember(u => u.CustomerOrderProductId, opt => opt.MapFrom(x => x.Id))
            .ForMember(u => u.CoverImageUrl, opt => opt.MapFrom(x => x.Product.CoverImageUrl))
            .ForMember(u => u.SellerName,
                       opt => opt.MapFrom(x => x.Product.Seller.Name + " " + x.Product.Seller.Fname))
            .ForMember(u => u.Count, opt => opt.MapFrom(x => x.OrderCount));

            CreateMap <CustomerAddress, CustomerAddressDto>()
            .ForMember(u => u.CityName, opt => opt.MapFrom(x => x.City.Name))
            .ForMember(u => u.ProvinceName, opt => opt.MapFrom(x => x.Province.Name));
        }
Пример #5
0
        public SingleResult <InsertOrderResultDto> GetProductByIdList_UI(OrderModel order)
        {
            try
            {
                var userId          = ClaimPrincipalFactory.GetUserId(User);
                var cc              = _repository.Customer.FindByCondition(c => c.UserId == userId).FirstOrDefault();
                var customerId      = cc.Id;
                var today           = DateTime.Now.AddDays(-1).Ticks;
                var orerProductList = new List <CustomerOrderProduct>();


                var orderNo = customerId.ToString() + DateTimeFunc.TimeTickToShamsi(DateTime.Now.Ticks).Replace("/", "") +
                              (_repository.CustomerOrder.FindByCondition(c => c.CustomerId == customerId && today > c.Cdate)
                               .Count() + 1).ToString().PadLeft(3, '0');


                order.ProductList.ForEach(c =>
                {
                    var product     = _repository.Product.FindByCondition(x => x.Id == c.ProductId).First();
                    var ofer        = _repository.Offer.FindByCondition(x => x.Id == c.OfferId).FirstOrDefault();
                    var packingType = _repository.ProductPackingType.FindByCondition(x => x.Id == c.PackingTypeId)
                                      .FirstOrDefault();
                    var statusId     = _repository.Status.GetSatusId("CustomerOrderProduct", 2);
                    var orderproduct = new CustomerOrderProduct
                    {
                        OrderCount           = c.Count,
                        ProductId            = c.ProductId,
                        Cdate                = DateTime.Now.Ticks,
                        CuserId              = userId,
                        OrderType            = 1,
                        ProductCode          = product.Coding,
                        ProductIncreasePrice = null,
                        ProductName          = product.Name,
                        ProductPrice         = product.Price,
                        ProductOfferId       = c.OfferId,
                        ProductOfferCode     = ofer?.OfferCode,
                        ProductOfferPrice    = (long?)(ofer != null ? (ofer.Value / 100 * product.Price) : 0),
                        ProductOfferValue    = ofer?.Value,
                        PackingTypeId        = packingType?.PackinggTypeId,
                        PackingWeight        = packingType == null ? 0 : packingType.Weight,
                        PackingPrice         = packingType == null ? 0 : packingType.Price,
                        SellerId             = product.SellerId,
                        Weight               = c.Count * product.Weight,
                        FinalWeight          = (c.Count * product.Weight) + (c.Count * (packingType == null ? 0 : packingType.Weight)),
                        FinalStatusId        = statusId
                    };
                    orerProductList.Add(orderproduct);
                });

                var offer         = _repository.Offer.FindByCondition(c => c.Id == order.OfferId).FirstOrDefault();
                var paking        = _repository.PackingType.FindByCondition(c => c.Id == order.PaymentTypeId).FirstOrDefault();
                var customerOrder = new CustomerOrder
                {
                    Cdate               = DateTime.Now.Ticks,
                    CuserId             = userId,
                    CustomerAddressId   = order.CustomerAddressId,
                    CustomerDescription = order.CustomerDescription,
                    CustomerId          = customerId,
                    FinalStatusId       = _repository.Status.GetSatusId("CustomerOrder", 1),
                    OfferId             = order.OfferId,
                    OrderPrice          = orerProductList.Sum(x =>
                                                              ((x.PackingPrice + x.ProductPrice - x.ProductOfferPrice) * x.OrderCount))
                };

                customerOrder.OrderPrice = orerProductList.Sum(c =>
                                                               (c.ProductPrice + c.PackingPrice - c.ProductOfferPrice) * c.OrderCount);
                customerOrder.OfferPrice =
                    (long?)(customerOrder.OrderPrice * (offer == null ? 0 : offer.Value / 100));
                customerOrder.OfferValue       = (int?)offer?.Value;
                customerOrder.OrderDate        = DateTime.Now.Ticks;
                customerOrder.FinalWeight      = orerProductList.Sum(x => x.FinalWeight);
                customerOrder.OrderNo          = Convert.ToInt64(orderNo);
                customerOrder.OrderProduceTime = 0;
                customerOrder.OrderType        = 1;
                customerOrder.OrderWeight      = customerOrder.FinalWeight;
                customerOrder.PackingPrice     = 0;
                customerOrder.PackingWeight    = 0;
                customerOrder.PaymentTypeId    = order.PaymentTypeId;
                customerOrder.PostServicePrice = 0;
                customerOrder.PostTypeId       = order.PostTypeId;

                //customerOrder.TaxPrice = (long?)((customerOrder.OrderPrice - customerOrder.OfferPrice) * 0.09);
                //customerOrder.TaxValue = 9;
                customerOrder.TaxPrice = 0;
                customerOrder.TaxValue = 9;


                customerOrder.CustomerOrderProduct = orerProductList;
                var toCityId = _repository.CustomerAddress.FindByCondition(c => c.Id == order.CustomerAddressId).Include(c => c.City).Select(c => c.City.PostCode).FirstOrDefault();


                var postType = _repository.PostType.FindByCondition(c => c.Id == order.PostTypeId).FirstOrDefault();
                var payType  = _repository.PaymentType.FindByCondition(c => c.Id == order.PaymentTypeId)
                               .FirstOrDefault();

                if (postType.IsFree.Value)
                {
                    customerOrder.PostServicePrice = 0;
                }
                else
                {
                    var post           = new PostServiceProvider();
                    var postpriceparam = new PostGetDeliveryPriceParam
                    {
                        Price       = (int)customerOrder.OrderPrice.Value,
                        Weight      = (int)customerOrder.FinalWeight.Value,
                        ServiceType = postType?.Rkey ?? 2,// (int)customerOrder.PostTypeId,
                        ToCityId    = (int)toCityId,
                        PayType     = (int)(payType?.Rkey ?? 88)
                    };
                    var postresult = post.GetDeliveryPrice(postpriceparam).Result;
                    if (postresult.ErrorCode != 0)
                    {
                        throw new BusinessException(XError.IncomingSerivceErrors.PostSeerivcError());
                    }
                    customerOrder.PostServicePrice = (postresult.PostDeliveryPrice + postresult.VatTax) / 10;
                }


                customerOrder.FinalPrice = customerOrder.OrderPrice + customerOrder.TaxPrice + customerOrder.PostServicePrice;
                _repository.CustomerOrder.Create(customerOrder);



                var request = new ZarinPallRequest
                {
                    //  amount = (int)((customerOrder.FinalPrice.Value + customerOrder.PostServicePrice) * 10),
                    amount      = (int)((customerOrder.FinalPrice.Value) * 10),
                    description = "order NO: " + customerOrder.OrderNo,
                    metadata    = new ZarinPalRequestMetaData
                    {
                        mobile = "0" + cc.Mobile.ToString(),
                        email  = cc.Email
                    }
                };
                var zarinPal = new ZarinPal();
                var res      = zarinPal.Request(request);

                var customerOrderPayment = new CustomerOrderPayment
                {
                    OrderNo          = customerOrder.OrderNo.ToString(),
                    TraceNo          = res.authority,
                    TransactionPrice = customerOrder.FinalPrice,
                    TransactionDate  = DateTime.Now.Ticks,
                    Cdate            = DateTime.Now.Ticks,
                    CuserId          = userId,
                    PaymentPrice     = customerOrder.FinalPrice,
                    FinalStatusId    = 26
                };
                customerOrder.CustomerOrderPayment.Add(customerOrderPayment);
                _repository.Save();

                var result = new InsertOrderResultDto
                {
                    OrderNo         = customerOrder.OrderNo,
                    CustomerOrderId = customerOrder.Id,
                    BankUrl         = "https://www.zarinpal.com/pg/StartPay/" + res.authority,
                    RedirectToBank  = true,
                    PostPrice       = customerOrder.PostServicePrice
                };
                var finalres = SingleResult <InsertOrderResultDto> .GetSuccessfulResult(result);

                _logger.LogData(MethodBase.GetCurrentMethod(), finalres, null, order);
                return(finalres);
            }
            catch (Exception e)
            {
                _logger.LogError(e, MethodBase.GetCurrentMethod(), order);
                return(SingleResult <InsertOrderResultDto> .GetFailResult(e.Message));
            }
        }
Пример #6
0
        public MappingProfile()
        {
            var now = DateTime.Now.Ticks;

            #region Color

            CreateMap <ColorDto, Color>();
            CreateMap <Color, ColorDto>();


            #endregion

            #region CatProduct

            CreateMap <CatProduct, CatProductDto>();
            CreateMap <CatProductDto, CatProduct>();
            CreateMap <CatProduct, CatProductWithCountDto>()
            .ForMember(u => u.ProductCount, opt => opt.MapFrom(x => x.Product.Where(y => y.DaDate == null && y.Ddate == null && y.FinalStatusId == 8).Count() + (x.InverseP.Sum(w => w.Product.Where(y => y.DaDate == null && y.Ddate == null && y.FinalStatusId == 8).Count()))));


            #endregion

            #region Slider

            CreateMap <Slider, SliderDto>();
            CreateMap <SliderDto, Slider>();

            #endregion

            #region SliderPlace

            CreateMap <SliderPlace, SliderPlaceDto>();
            CreateMap <SliderPlaceDto, SliderPlace>();

            #endregion

            #region PackingType

            CreateMap <PackingTypeDto, PackingType>();
            CreateMap <PackingType, PackingTypeDto>()
            .ForMember(u => u.PackingTypeImage, opt => opt.MapFrom(x => x.PackingTypeImage));


            #endregion

            #region PackingTypeImage

            CreateMap <PackingTypeImageDto, PackingTypeImage>();
            CreateMap <PackingTypeImage, PackingTypeImageDto>();

            #endregion

            #region PostType

            CreateMap <PostTypeDto, PostType>();
            CreateMap <PostType, PostTypeDto>();



            #endregion

            #region FamousComments

            CreateMap <FamousCommentsDto, FamousComments>();
            CreateMap <FamousComments, FamousCommentsDto>();



            #endregion

            #region Parameters

            CreateMap <ParametersDto, Parameters>();
            CreateMap <Parameters, ParametersDto>();



            #endregion

            #region CatProductParameters

            CreateMap <CatProductParameters, CatProductParametersDto>();
            CreateMap <CatProductParametersDto, CatProductParameters>();



            #endregion

            #region ProductCatProductParameters


            CreateMap <ProductCatProductParameters, ProductParamDto>()
            .ForMember(u => u.ParameterName, opt => opt.MapFrom(x => x.CatProductParameters.Parameters.Name));
            CreateMap <ProductParamDto, ProductCatProductParameters>();



            #endregion

            #region ProductImage

            CreateMap <ProductImageDto, ProductImage>();
            CreateMap <ProductImage, ProductImageDto>();

            #endregion

            #region Product


            CreateMap <Product, ProductDto>()
            .ForMember(u => u.CatProductName, opt => opt.MapFrom(x => x.CatProduct.Name))
            .ForMember(u => u.SellerName, opt => opt.MapFrom(x => x.Seller.Name + " " + x.Seller.Fname))
            .ForMember(u => u.FinalStatus, opt => opt.MapFrom(x => x.FinalStatus.Name))
            .ForMember(u => u.LastSeenDate,
                       opt => opt.MapFrom(x => DateTimeFunc.TimeTickToShamsi(x.LastSeenDate.Value)))
            .ForMember(u => u.Rating, opt => opt.MapFrom(x => x.ProductCustomerRate.Average(c => c.Rate)))
            .ForMember(u => u.OfferId,
                       opt => opt.MapFrom(x =>
                                          x.ProductOffer
                                          .Where(c => c.FromDate < now && now < c.ToDate && c.DaDate == null &&
                                                 c.Ddate == null).Select(c => c.OfferId).FirstOrDefault()))
            .ForMember(u => u.OfferPercent, opt => opt.MapFrom(x =>
                                                               x.ProductOffer
                                                               .Where(c => c.FromDate < now && now < c.ToDate && c.DaDate == null &&
                                                                      c.Ddate == null).Select(c => c.Value).DefaultIfEmpty(0).FirstOrDefault()))
            .ForMember(u => u.OfferAmount, opt => opt.MapFrom(x =>
                                                              (x.ProductOffer
                                                               .Where(c => c.FromDate < now && now < c.ToDate && c.DaDate == null &&
                                                                      c.Ddate == null).Select(c => c.Value).DefaultIfEmpty(0).FirstOrDefault()) *
                                                              x.Price / 100))
            .ForMember(u => u.PriceAftterOffer, opt => opt.MapFrom(x =>
                                                                   x.Price - ((x.ProductOffer
                                                                               .Where(c => c.FromDate < now && now < c.ToDate && c.DaDate == null &&
                                                                                      c.Ddate == null).Select(c => c.Value).DefaultIfEmpty(0)
                                                                               .FirstOrDefault()) * x.Price /
                                                                              100)))
            .ForMember(u => u.OfferDeadLine, opt => opt.MapFrom(x =>
                                                                x.ProductOffer
                                                                .Where(c => c.FromDate < now && now < c.ToDate && c.DaDate == null &&
                                                                       c.Ddate == null).Select(c => c.ToDate != null ? new DateTime(c.ToDate.Value) : new DateTime(1988, 12, 13)).FirstOrDefault()));

            CreateMap <Product, ProductGeneralSearchResultDto>()
            .ForMember(u => u.ProductId, opt => opt.MapFrom(x => x.Id))
            .ForMember(u => u.ProductName, opt => opt.MapFrom(x => x.Name))
            .ForMember(u => u.CatProductId, opt => opt.MapFrom(x => x.CatProduct.Id))
            .ForMember(u => u.CatProductName, opt => opt.MapFrom(x => x.CatProduct.Name))
            .ForMember(u => u.CatProductCode, opt => opt.MapFrom(x => x.CatProduct.Coding));


            #endregion

            #region ProductCustomerRate

            CreateMap <ProductCustomerRate, ProductCustomerRateDto>()
            .ForMember(u => u.CustomerName, opt => opt.MapFrom(x => x.Customer.Name + " " + x.Customer.Fname))
            .ForMember(u => u.ProductCustomerRateImages, opt => opt.MapFrom(x => x.ProductCustomerRateImage));

            #endregion

            #region ProductCustomerRateImage

            CreateMap <ProductCustomerRateImage, ProductCustomerRateImageDto>();

            #endregion

            #region ProductColor

            CreateMap <ProductColor, ProductColorDto>()
            .ForMember(u => u.ColorName, opt => opt.MapFrom(x => x.Color.Name))
            .ForMember(u => u.ColorCode, opt => opt.MapFrom(x => x.Color.ColorCode));
            CreateMap <ProductColorDto, ProductColor>();

            #endregion

            #region ProductPackingType

            CreateMap <ProductPackingType, ProductPackingTypeDto>()
            .ForMember(u => u.PackingTypeName, opt => opt.MapFrom(x => x.PackinggType.Name));

            #endregion

            #region CustomerAddress

            CreateMap <CustomerAddress, CustomerAddressDto>()
            .ForMember(u => u.CityName, opt => opt.MapFrom(x => x.City.Name))
            .ForMember(u => u.ProvinceName, opt => opt.MapFrom(x => x.Province.Name));
            CreateMap <CustomerAddressDto, CustomerAddress>();
            #endregion

            #region PaymentType

            CreateMap <PaymentType, PaymentTypeDto>();

            #endregion

            #region Package

            CreateMap <Package, PackageDto>()
            .ForMember(u => u.StartDate,
                       opt => opt.MapFrom(x => DateTimeFunc.TimeTickToShamsi(x.StartDateTime.Value)))
            .ForMember(u => u.EndDate, opt => opt.MapFrom(x => DateTimeFunc.TimeTickToShamsi(x.EndDateTime.Value)));

            #endregion

            #region PackageImage

            CreateMap <PackageImage, PackageImageDto>();

            #endregion

            #region Offer

            CreateMap <Offer, OfferDto>()
            .ForMember(u => u.OfferId, opt => opt.MapFrom(x => x.Id))
            .ForMember(u => u.CustomerOfferId, opt => opt.MapFrom(x => x.Id));


            CreateMap <OfferDto, Offer>();
            #endregion

            #region CustomerOffer

            CreateMap <CustomerOffer, OfferDto>()
            .ForMember(u => u.OfferId, opt => opt.MapFrom(x => x.OfferId))
            .ForMember(u => u.CustomerOfferId, opt => opt.MapFrom(x => x.Id));



            #endregion

            #region Location

            CreateMap <Location, LocationDto>();

            #endregion

            #region CustomerOrderProduct

            CreateMap <CustomerOrderProduct, CustomerOrderProductDto>()
            .ForMember(u => u.SellerName, opt => opt.MapFrom(x => x.Seller.Name + " " + x.Seller.Fname))
            .ForMember(u => u.StatusName, opt => opt.MapFrom(x => x.FinalStatus.Name))
            .ForMember(u => u.PackingTypeName, opt => opt.MapFrom(x => x.PackingType.Name))
            .ForMember(u => u.ProductImage, opt => opt.MapFrom(x => x.Product.CoverImageUrl));


            CreateMap <CustomerOrderProduct, CustomerOrderProductSampleDto>()
            .ForMember(u => u.CoverImage, opt => opt.MapFrom(x => x.Product.CoverImageUrl));

            #endregion

            #region CustomerOrder

            CreateMap <CustomerOrder, CustomerOrderFullDto>()
            .ForMember(u => u.DeliveryDate,
                       opt => opt.MapFrom(x =>
                                          x.DeliveryDate == null ? "" : DateTimeFunc.TimeTickToShamsi(x.DeliveryDate.Value)))
            .ForMember(u => u.OrderDate,
                       opt => opt.MapFrom(x =>
                                          x.OrderDate == null ? "" : DateTimeFunc.TimeTickToShamsi(x.OrderDate.Value)))
            .ForMember(u => u.SendDate,
                       opt => opt.MapFrom(x =>
                                          x.SendDate == null ? "" : DateTimeFunc.TimeTickToShamsi(x.SendDate.Value)))
            .ForMember(u => u.PaymentTypeName, opt => opt.MapFrom(x => x.PaymentType.Title))
            .ForMember(u => u.PostTypeName, opt => opt.MapFrom(x => x.PostType.Title))
            .ForMember(u => u.FinalStatus, opt => opt.MapFrom(x => x.FinalStatus.Name))
            .ForMember(u => u.CustomerAddress,
                       opt => opt.MapFrom(x =>
                                          x.CustomerAddress.Province.Name + " - " + x.CustomerAddress.City.Name + " - " +
                                          x.CustomerAddress.Address))
            .ForMember(u => u.CustomerMobile, opt => opt.MapFrom(x => x.Customer.Mobile))
            .ForMember(u => u.CustomerName, opt => opt.MapFrom(x => x.Customer.Name + " " + x.Customer.Fname))
            .ForMember(u => u.PaymentStatus,
                       opt => opt.MapFrom(x =>
                                          x.CustomerOrderPayment.Where(c => c.Ddate == null && c.DaDate == null)
                                          .OrderByDescending(c => c.TransactionDate).Select(c => c.FinalStatus.Name)
                                          .FirstOrDefault()))
            .ForMember(u => u.CustomerOrderProductsList, opt => opt.MapFrom(x => x.CustomerOrderProduct))
            .ForMember(u => u.CustomerOrderPaymentList, opt => opt.MapFrom(x => x.CustomerOrderPayment));


            CreateMap <CustomerOrder, CustomerOrderDto>()
            .ForMember(u => u.DeliveryDate,
                       opt => opt.MapFrom(x =>
                                          x.DeliveryDate == null ? "" : DateTimeFunc.TimeTickToShamsi(x.DeliveryDate.Value)))
            .ForMember(u => u.OrderDate,
                       opt => opt.MapFrom(x =>
                                          x.OrderDate == null ? "" : DateTimeFunc.TimeTickToShamsi(x.OrderDate.Value)))
            .ForMember(u => u.SendDate,
                       opt => opt.MapFrom(x =>
                                          x.SendDate == null ? "" : DateTimeFunc.TimeTickToShamsi(x.SendDate.Value)))
            .ForMember(u => u.PaymentTypeName, opt => opt.MapFrom(x => x.PaymentType.Title))
            .ForMember(u => u.PostTypeName, opt => opt.MapFrom(x => x.PostType.Title))
            .ForMember(u => u.FinalStatus, opt => opt.MapFrom(x => x.FinalStatus.Name))
            .ForMember(u => u.PaymentStatus,
                       opt => opt.MapFrom(x =>
                                          x.CustomerOrderPayment.Where(c => c.Ddate == null && c.DaDate == null)
                                          .OrderByDescending(c => c.TransactionDate).Select(c => c.FinalStatus.Name)
                                          .FirstOrDefault()))
            .ForMember(u => u.ProductList, opt => opt.MapFrom(x => x.CustomerOrderProduct));



            #endregion

            #region CustomerOrderPayment

            CreateMap <CustomerOrderPayment, CustomerOrderPaymentDto>()
            .ForMember(u => u.FinalStatus, opt => opt.MapFrom(x => x.FinalStatus.Name))
            .ForMember(u => u.TransactionDate,
                       opt => opt.MapFrom(x =>
                                          x.TransactionDate == null ? "---" : DateTimeFunc.TimeTickToShamsi(x.TransactionDate.Value)));
            #endregion

            #region Document

            CreateMap <Document, DocumentDto>()
            .ForMember(u => u.CatDocumentName,
                       opt => opt.MapFrom(x => x.CatDocument.Title));
            CreateMap <DocumentDto, Document>();
            #endregion

            #region Work

            CreateMap <Work, WorkDto>();
            CreateMap <WorkDto, Work>();

            #endregion

            #region Customer

            CreateMap <CustomerProfileDto, Customer>();
            CreateMap <Customer, CustomerProfileDto>().ForMember(u => u.Bdate,
                                                                 opt => opt.MapFrom(x => x.Bdate == null ? DateTime.Now.ToString() : DateTimeFunc.TimeTickToMiladi(x.Bdate.Value)));

            #endregion

            #region SellerDocument

            CreateMap <SellerDocument, SellerDocumentDto>()
            .ForMember(u => u.DocumentName,
                       opt => opt.MapFrom(x => x.Document.Title))
            .ForMember(u => u.FianlStatus,
                       opt => opt.MapFrom(x => x.FianlStatus.Name));


            #endregion

            #region Seller

            CreateMap <Seller, SellerFullInfoDto>()
            .ForMember(u => u.Bdate,
                       opt => opt.MapFrom(x => x.Bdate == null ? DateTime.Now.ToString() : DateTimeFunc.TimeTickToMiladi(x.Bdate.Value)))
            .ForMember(u => u.RegisterDate,
                       opt => opt.MapFrom(x => x.Cdate == null ? DateTime.Now.ToString() : DateTimeFunc.TimeTickToMiladi(x.Cdate.Value)))
            .ForMember(u => u.AddressList,
                       opt => opt.MapFrom(x => x.SellerAddress))
            .ForMember(u => u.DocumentList,
                       opt => opt.MapFrom(x => x.SellerDocument))
            .ForMember(u => u.SellerId,
                       opt => opt.MapFrom(x => x.Id));

            #endregion

            #region SellerAddress

            CreateMap <SellerAddress, SellerAddressDto>();


            #endregion

            #region DynamicForms

            CreateMap <DynamiFormImage, DynamiFormImageDto>();
            CreateMap <DynamiFormDto, DynamicForms>();
            CreateMap <DynamicForms, DynamiFormDto>()
            .ForMember(u => u.ImageList,
                       opt => opt.MapFrom(x => x.DynamiFormImage.Where(c => c.Ddate == null && c.DaDate == null)));

            #endregion

            #region SellerComment

            CreateMap <SellerComment, SellerCommentDto>()
            .ForMember(u => u.SellerName,
                       opt => opt.MapFrom(x => x.Seller.Name + " " + x.Seller.Fname))
            .ForMember(u => u.CommentType,
                       opt => opt.MapFrom(x => x.CommentType == 1 ? "بیوگرافی" : "نظر"))
            .ForMember(u => u.Status,
                       opt => opt.MapFrom(x => x.FinalStatus.Name))
            .ForMember(u => u.ProfileImage,
                       opt => opt.MapFrom(x => x.Seller.ProfileImageUrl));



            CreateMap <SellerCommentDto, SellerComment>();

            #endregion
        }