public IOrderBaseFullInfoDto Get(long id)
        {
            var order  = _orderRepository.Find(id);
            var result = order.ToOrderBaseFullInfoDto();

            return(result);
        }
        public IOrderSuggestionDto GetByOrderId(long orderId)
        {
            var      order                    = _orderRepository.Find(orderId);
            var      now                      = DateTime.Now;
            DateTime startDateTime            = DateTime.Today;                         //Today at 00:00:00
            DateTime endDateTime              = DateTime.Today.AddDays(1).AddTicks(-1); //Today at 23:59:59
            var      havePercentDiscountToday = _factorRepository.AsQuery()
                                                .Where(p => p.CreationTime >= startDateTime &&
                                                       p.CreationTime <= endDateTime &&
                                                       p.Customer.Id == order.Customer.Id &&
                                                       p.FactorState == FactorState.Paid)
                                                .SelectMany(p => p.FactorRaws)
                                                .Any(p => p.Discount != null && p.Discount is FactorRawPercentDiscount &&
                                                     p.Discount.FromDate <= now &&
                                                     p.Discount.ToDate >= now &&
                                                     (p.Discount as FactorRawPercentDiscount).FromTime <= now.TimeOfDay &&
                                                     (p.Discount as FactorRawPercentDiscount).ToTime >= now.TimeOfDay);
            //todo autho
            var t = _repository.AsQuery().Where(p => p.OrderId == orderId).ToList();
            var orderSuggestion = _repository.AsQuery().SingleOrDefault(p => p.OrderId == orderId);

            if (!havePercentDiscountToday)
            {
                return(orderSuggestion.ToDo());
            }
            if (orderSuggestion == null)
            {
                return(((OrderSuggestion)null).ToDo());
            }
            foreach (var item in orderSuggestion.OrderSuggestionItems)
            {
                item.OrderItem.Discount = null;
            }
            return(orderSuggestion.ToDo());
        }
Esempio n. 3
0
        public ICustomerProductSuggestionDto GetById(Guid id)
        {
            var productSuggestion = _repository.Find(id);
            var result            = productSuggestion.ToDto();
            var person            = _personRepository.Find(productSuggestion.PersonId);

            result.FullName = person.FirstName + person.LastName;
            return(result);
        }
        public async Task <ActionResult> Index()
        {
            var viewModel = new CartIndexViewModel
            {
                Carts     = await _cartReader.Find(x => true),
                Customers = await _customerRepository.Find(x => true)
            };

            return(View(viewModel));
        }
        public async Task <ActionResult> Details(string id)
        {
            var viewModel = new CartDetailsViewModel
            {
                Cart      = await _cartReader.Get(id),
                CartItems = await _cartReader.GetCartItems(id),
                Products  = await _productRepository.Find(x => true)
            };

            return(View(viewModel));
        }
        public IEnumerable <IShopPositionDto> GetShopsByCityId(Guid cityId)
        {
            var city = _cityRepository.Find(cityId);

            if (city == null)
            {
                throw new DomainException("شهر یافت نشد");
            }
            var result = _repository.AsQuery().Where(p => p.ShopAddress.CityId == cityId).ToList();

            return(result.Select(p => p.ToShopPositionDto()));
        }
Esempio n. 7
0
        public async Task <MobilePagingResultDto <IProductDiscountDto> > GetProductPercentDiscountByIdPaging(Guid percentDiscountId, PagedInputDto pagedInput)
        {
            var percentDiscount = _percentRepository.Find(percentDiscountId);

            if (percentDiscount == null)
            {
                throw new DomainException("تخفیف یافت نشد");
            }
            if (!(percentDiscount.FromDate <= DateTime.Today &&
                  percentDiscount.ToDate >= DateTime.Today))
            {
                throw new DomainException("تخفیف در این بازه زمانی روز موجود نمی باشد");
            }
            if (!(percentDiscount.FromTime <= DateTime.Now.TimeOfDay &&
                  percentDiscount.ToTime >= DateTime.Now.TimeOfDay))
            {
                throw new DomainException("تخفیف در این بازه زمانی ساعت موجود نمی باشد");
            }
            if (percentDiscount.RemainOrderCount <= 0)
            {
                throw new DomainException("تخفیف در این بازه زمانی ساعت موجود نمی باشد");
            }
            var data = _percentRepository.AsQuery().Where(item => item.Id == percentDiscountId)
                       .SelectMany(item => item.ProductDiscounts);
            var result = await data.OrderByDescending(p => p.CreationTime)
                         .Skip(pagedInput.Skip)
                         .Take(pagedInput.Count)
                         .ToListAsync();

            return(new MobilePagingResultDto <IProductDiscountDto>
            {
                Result = result.Select(item => item.ToDto())
                         .ToList(),
                Count = data.Count()
            });
        }
        /// <summary>
        /// Returns instance of type <typeparamref name="TDomainModel"/> associated with the <paramref name="key"/> in the <paramref name="repository"/>.
        /// If no such instance exists, throws <see cref="AggregateRootNotFoundException"/>.
        /// </summary>
        /// <typeparam name="TDomainModel">The type of the model to return.</typeparam>
        /// <typeparam name="TKey">The type of the key.</typeparam>
        /// <param name="repository">The repository.</param>
        /// <param name="key">The key to model associated with.</param>
        /// <returns>The instance of model associated with the <paramref name="key"/>.</returns>
        /// <exception cref="AggregateRootNotFoundException">When no such model is associated with the <paramref name="key"/>.</exception>
        public static TDomainModel Get <TDomainModel, TKey>(this IReadOnlyRepository <TDomainModel, TKey> repository, TKey key)
            where TDomainModel : IDomainModel <TKey>
            where TKey : IKey
        {
            Ensure.NotNull(repository, "repository");

            TDomainModel model = repository.Find(key);

            if (model == null)
            {
                throw new AggregateRootNotFoundException(key);
            }

            return(model);
        }
Esempio n. 9
0
        public IDeleteContext Handle(IKey key)
        {
            TKey modelKey = key as TKey;

            Ensure.NotNull(modelKey, "key");

            TModel model = repository.Find(modelKey);

            if (model == null)
            {
                return(new MissingHandlerContext(key));
            }

            return(HandleModel(model));
        }
Esempio n. 10
0
        public IList <IBrandDto> GetActiveCategoryBrands(Guid categoryId)
        {
            var category = _categoryBaseRepository.Find(categoryId);

            if (category == null)
            {
                throw new DomainException("دسته بندی یافت نشد");
            }
            var categoryProducts = _productRepository.AsQuery().Where(p => p.Category.Id == category.Id);
            var brands           = categoryProducts.GroupBy(p => p.Brand).Where(item => item.Key.IsActive).Select(item => new
            {
                item.Key
            }).ToList().Select(item => item.Key.ToDto()).ToList();

            return(brands);
        }
Esempio n. 11
0
 private Vehicle FindVehicle(Guid id)
 {
     return(_VehicleReadOnlyRepository.Find(id));
 }
Esempio n. 12
0
        public IActionResult Service(Guid id)
        {
            var obj = _serviceReadOnlyRepository.Find(id);

            return(Ok(obj));
        }
Esempio n. 13
0
 private Owner FindOwner(Guid id)
 {
     return(_ownerReadOnlyRepository.Find(id));
 }
Esempio n. 14
0
 public TAggregateRoot Find(TKey ID)
 => _inner.Find(ID);
Esempio n. 15
0
 private ServiceOrder FindServiceOrder(Guid id)
 {
     return(_serviceOrderReadOnlyRepository.Find(id));
 }
        public ICustomerWithAddressesDto Get(Guid id)
        {
            var customer = _repository.Find(id);

            return(customer.ToCustomerWithAddressesDto());
        }
Esempio n. 17
0
 public Task <IEnumerable <CartItem> > GetCartItems(string cartId)
 {
     return(_cartItemRepository.Find(x => x.CartId == cartId));
 }
Esempio n. 18
0
 public Task <IEnumerable <Cart.Cart> > Find(Expression <Func <Cart.Cart, bool> > predicate)
 {
     return(_cartRepository.Find(predicate));
 }
Esempio n. 19
0
 public void GetHistory(IReadOnlyRepository <VehicleHistoryAdapter> readRepository)
 {
     vehicleHistory = readRepository.Find(id);
 }
Esempio n. 20
0
        public IShopFullInfo GetById(Guid id)
        {
            var result = _repository.Find(id);

            return(result.ToShopFullInfoDto());
        }
Esempio n. 21
0
 public bool Execute()
 {
     return(_deleteRepository.Remove(_readRepository.Find(_id)) != null);
 }
Esempio n. 22
0
        public IBrandDto GetBrandById(Guid id)
        {
            var result = _brandRepository.Find(id);

            return(result.ToDto());
        }
        public ICategoryBaseWithImageDto GetCategoryById(Guid id)
        {
            var result = _categoryRepository.Find(id);

            return(result.ToCategoryBaseWithImageDto());
        }
Esempio n. 24
0
        public IProductWithImageDto GetById(Guid id)
        {
            var result = _repository.Find(id).ToProductWithImageDto();

            return(result);
        }
Esempio n. 25
0
 public virtual IEnumerable <TEntity> Find(Expression <Func <TEntity, bool> > predicate)
 {
     return(_readOnlyRepository.Find(predicate));
 }
Esempio n. 26
0
 private Service FindService(Guid id)
 {
     return(_serviceReadOnlyRepository.Find(id));
 }
Esempio n. 27
0
 public virtual IEnumerable <TEntity> Find(Expression <Func <TEntity, bool> > predicate, bool @readonly = false)
 {
     return(@readonly
         ? _readOnlyRepository.Find(predicate)
         : _repository.Find(predicate));
 }