コード例 #1
0
        public async Task <IResponse <ProductDTO> > FindAsDtoAsync(int id)
        {
            var product = await _productRepo.FirstOrDefaultAsync(conditions : x => !x.IsDeleted && x.ProductId == id && x.IsActive,
                                                                 new List <Expression <Func <Product, object> > > {
                x => x.ProductAssets
            });

            if (product == null)
            {
                return new Response <ProductDTO>
                       {
                           IsSuccessful = false,
                           Message      = ServiceMessage.RecordNotExist
                       }
            }
            ;
            var currentDT = DateTime.Now;
            var discount  = await _discountRepo.FirstOrDefaultAsync(conditions : x => x.StoreId == product.StoreId && x.ValidFromDateMi <= currentDT && x.ValidToDateMi >= currentDT);

            return(new Response <ProductDTO>
            {
                IsSuccessful = true,
                Result = new ProductDTO
                {
                    Id = product.ProductId,
                    Price = product.Price,
                    Discount = product.DiscountPercent,
                    Name = product.Name,
                    Description = product.Description,
                    Slides = product.ProductAssets?.Select(x => x.FileUrl).ToList()
                }
            });
        }
コード例 #2
0
        public async Task <IResponse <LocationDTO> > GetLocationAsync(int id)
        {
            var addressId = await _storeRepo.FirstOrDefaultAsync(x => x.AddressId, x => x.StoreId == id && x.IsActive, includeProperties : null);//await _storeRepo.FirstOrDefaultAsync(x => x.AddressId, x => x.StoreId == id && x.IsActive, includeProperties: null);

            if (addressId == null)
            {
                return new Response <LocationDTO> {
                           Message = ServiceMessage.RecordNotExist
                }
            }
            ;
            var address = await _appUow.AddressRepo.FindAsync(addressId);

            if (address == null)
            {
                return new Response <LocationDTO> {
                           Message = ServiceMessage.RecordNotExist
                }
            }
            ;
            return(new Response <LocationDTO>
            {
                IsSuccessful = true,
                Result = new LocationDTO
                {
                    Lat = address.Latitude,
                    Lng = address.Longitude
                }
            });
        }
コード例 #3
0
        public async Task <IResponse <Address> > FindAsync(int id)
        {
            var address = await _addressRepo.FirstOrDefaultAsync(x => x.AddressId == id, new System.Collections.Generic.List <Expression <Func <Address, object> > > {
                x => x.User
            });

            if (address == null)
            {
                return new Response <Address> {
                           Message = ServiceMessage.RecordNotExist
                }
            }
            ;
            return(new Response <Address> {
                Result = address, IsSuccessful = true
            });
        }
    }
コード例 #4
0
        public async Task <IResponse <(IGatewayService Service, PaymentGateway Gateway)> > GetInsance(int gatewayId)
        {
            var paymentGateway = await _paymentGatewayRepo.FirstOrDefaultAsync(conditions : x => x.PaymentGatewayId == gatewayId, includeProperties : null);

            if (paymentGateway.Name == null)
            {
                return new Response <(IGatewayService Service, PaymentGateway Gateway)> {
                           Message = ServiceMessage.RecordNotExist
                }
            }
            ;
            switch (paymentGateway.Name)
            {
            default:
                return(new Response <(IGatewayService Service, PaymentGateway Gateway)> {
                    IsSuccessful = true, Result = (new HillaPayService(), paymentGateway)
                });
            }
        }
    }
コード例 #5
0
        public async Task <IResponse <Relative> > FindAsync(int id)
        {
            var relative = await _RelativeRepo.FirstOrDefaultAsync(x => x.RelativeId == id,
                                                                   new List <Expression <Func <Relative, object> > > {
                x => x.RelativeAttachments
            });

            if (relative == null)
            {
                return new Response <Relative> {
                           Message = ServiceMessage.RecordNotExist
                }
            }
            ;
            if (relative.RelativeAttachments != null)
            {
                relative.RelativeAttachments = relative.RelativeAttachments.Where(x => !x.IsDeleted).ToList();
            }
            return(new Response <Relative> {
                Result = relative, IsSuccessful = true
            });
        }