Beispiel #1
0
 public IActionResult GetOfferList()
 {
     try
     {
         var res = _repository.Offer.FindByCondition(c => c.Ddate == null)
                   .Include(c => c.OfferType)
                   .Include(c => c.ProductOffer).ThenInclude(c => c.Product)
                   .Select(c => new
         {
             c.Id,
             c.Name,
             FromDate = DateTimeFunc.TimeTickToMiladi(c.FromDate.Value),
             ToDate   = DateTimeFunc.TimeTickToMiladi(c.ToDate.Value),
             c.MaximumPrice,
             c.Value,
             c.Description,
             Type        = c.OfferType.Name,
             Status      = c.DaDate == null ? "فعال" : "غیرفعال",
             ProductList = c.ProductOffer.Select(x => string.Join('-', x.Product.Name)).FirstOrDefault()
         }).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));
     }
 }
Beispiel #2
0
        public IActionResult GetProductOfferHistoryList(long productId)
        {
            try
            {
                var offerlist = _repository.ProductOffer
                                .FindByCondition(c => c.Ddate == null && c.ProductId == productId)
                                .Select(c => c.OfferId);

                var res = _repository.Offer
                          .FindByCondition(c => c.Ddate == null && offerlist.Contains(c.Id)).Include(c => c.OfferType)
                          .Select(c => new
                {
                    c.Id,
                    c.Name,
                    FromDate = DateTimeFunc.TimeTickToMiladi(c.FromDate.Value),
                    ToDate   = DateTimeFunc.TimeTickToMiladi(c.ToDate.Value),
                    c.MaximumPrice,
                    c.Value,
                    c.Description,
                    Type   = c.OfferType.Name,
                    Status = c.DaDate == null ? "فعال" : "غیرفعال"
                }).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));
            }
        }
        public IActionResult GetCustomerRateList()
        {
            try
            {
                var res = _repository.ProductCustomerRate
                          .FindByCondition(c => c.Ddate == null && c.DaDate == null && c.Pid == null)
                          .Include(c => c.Product)
                          .Include(c => c.Customer)
                          .Include(c => c.FinalStatus)
                          .Select(c => new
                {
                    c.Id,
                    c.Rate,
                    c.CommentDesc,
                    CommentDate   = DateTimeFunc.TimeTickToMiladi(c.CommentDate.Value),
                    ProductName   = c.Product.Name,
                    ProductCoding = c.Product.Coding,
                    CustomerName  = c.Customer.Name + " " + c.Customer.Fname,
                    c.FinalStatusId,
                    Status = c.FinalStatus.Name
                }).ToList();

                _logger.LogData(MethodBase.GetCurrentMethod(), res, null);
                return(Ok(res));
            }
            catch (Exception e)
            {
                _logger.LogError(e, MethodBase.GetCurrentMethod());
                return(BadRequest(e.Message));
            }
        }
Beispiel #4
0
        public IActionResult GetOfferFullInfoById(long offerId)
        {
            try
            {
                var offer = _repository.Offer.FindByCondition(c => c.Id == offerId).Include(c => c.OfferType).Select(c => new
                {
                    c.Id,
                    c.Name,
                    FromDate = DateTimeFunc.TimeTickToMiladi(c.FromDate.Value),
                    ToDate   = DateTimeFunc.TimeTickToMiladi(c.ToDate.Value),
                    c.MaximumPrice,
                    c.Value,
                    c.Description,
                    c.OfferCode,
                    c.UsedCount,
                    c.UsageCount,
                    c.UsageValue,
                    Type   = c.OfferType.Name,
                    Status = c.DaDate == null ? "فعال" : "غیرفعال"
                }).FirstOrDefault();
                if (offer == null)
                {
                    throw new BusinessException(XError.GetDataErrors.NotFound());
                }

                var productIdList = _repository.ProductOffer.FindByCondition(c => c.OfferId == offerId)
                                    .Include(c => c.Product).Select(c => c.ProductId);

                var productList = _repository.Product
                                  .FindByCondition(c => productIdList.Contains(c.Id) && c.DaDate == null && c.Ddate == null)
                                  .Include(c => c.CatProduct)
                                  .Include(c => c.Seller)
                                  .Select(c => new
                {
                    c.Id,
                    c.Name,
                    c.Price,
                    c.Coding,
                    CatProduct = c.CatProduct.Name,
                    SellerName = c.Seller.Name + " " + c.Seller.Fname,
                    c.Count
                }).ToList();

                var res = new { Offer = offer, ProductList = productList };

                _logger.LogData(MethodBase.GetCurrentMethod(), res, null, offerId);
                return(Ok(res));
            }
            catch (Exception e)
            {
                _logger.LogError(e, MethodBase.GetCurrentMethod(), offerId);
                return(BadRequest(e.Message));
            }
        }
 public IActionResult GetCustomerOrderHistory(long customerId)
 {
     try
     {
         var res = _repository.CustomerOrder.FindByCondition(c => c.CustomerId == customerId)
                   .Include(c => c.FinalStatus)
                   .Select(c => new { c.OrderNo, OrderDate = DateTimeFunc.TimeTickToMiladi(c.OrderDate.Value), c.FinalPrice, Status = c.FinalStatus.Name }).ToList();
         _logger.LogData(MethodBase.GetCurrentMethod(), res, null, customerId);
         return(Ok(res));
     }
     catch (Exception e)
     {
         _logger.LogError(e, MethodBase.GetCurrentMethod(), customerId);
         return(BadRequest(e.Message));
     }
 }
        public IActionResult GetProductPackingTypeHistory(long productId)
        {
            try
            {
                var res = _repository.ProductPackingType.FindByCondition(c => c.Ddate == null && c.DaDate == null && c.ProductId == productId)
                          .Include(c => c.PackinggType)
                          .Select(c => new
                {
                    c.PackinggType.Name,
                    CreationDate = DateTimeFunc.TimeTickToMiladi(c.Cdate.Value)
                }).ToList();

                _logger.LogData(MethodBase.GetCurrentMethod(), res, null, productId);
                return(Ok(res));
            }
            catch (Exception e)
            {
                _logger.LogError(e, MethodBase.GetCurrentMethod(), productId);
                return(BadRequest(e.Message));
            }
        }
Beispiel #7
0
        public IActionResult GetCurrentSellerInfo()
        {
            try
            {
                var userId = ClaimPrincipalFactory.GetUserId(User);
                var res    = _repository.Seller.FindByCondition(c => c.UserId == userId).Select(c =>
                                                                                                new
                {
                    c.Id, c.Name, c.Fname, c.MelliCode, c.Mobile, c.Email, Password = c.User.Hpassword,
                    BirthDate = DateTimeFunc.TimeTickToMiladi(c.Bdate.Value), c.ShabaNo
                }).FirstOrDefault();

                _logger.LogData(MethodBase.GetCurrentMethod(), res, null);
                return(Ok(res));
            }
            catch (Exception e)
            {
                _logger.LogError(e, MethodBase.GetCurrentMethod());
                return(BadRequest(e.Message));
            }
        }
Beispiel #8
0
        public IActionResult BuyCardBoughtHistory(long productId)
        {
            try
            {
                var res = _repository.CustomerOrderProduct.FindByCondition(c => c.ProductId == productId && c.CustomerOrder.CustomerOrderPayment.Any(x => x.FinalStatusId == 25))
                          .Include(c => c.CustomerOrder).ThenInclude(c => c.Customer)
                          .Select(c => new
                {
                    CustomerName = c.CustomerOrder.Customer.Name + c.CustomerOrder.Customer.Name,
                    OrderDate    = DateTimeFunc.TimeTickToMiladi(c.CustomerOrder.OrderDate.Value),
                    c.CustomerOrder.OrderNo
                }).ToList();


                _logger.LogData(MethodBase.GetCurrentMethod(), res, null, productId);
                return(Ok(res));
            }
            catch (Exception e)
            {
                _logger.LogError(e, MethodBase.GetCurrentMethod(), productId);
                return(BadRequest(e.Message));
            }
        }
Beispiel #9
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
        }