public ReturnPurchasesService(UnitOfWork unitOfWork) : base(unitOfWork, unitOfWork.ReturnPurchases)
 {
 }
 public ProductCategoriesService(UnitOfWork unitOfWork) : base(unitOfWork, repository: unitOfWork.ProductCategories)
 {
 }
        public void RequestOrderItem(Guid userId, int amount, Guid itemId, string notes)
        {
            User   user = null;
            ItemVM item = null;

            //1-find user
            user = UserService.FindByGuid(userId);


            //2-find order
            CreateOrderIfNotExist();



            ResponseService.Init();
            if (user == null)
            {
                ResponseService.Status = false;
                ResponseService.Errors.Add("User Not Found");
                return;
            }


            Order order = FindCurrentOrder();

            if (order.Ordered)
            {
                ResponseService.Status = false;
                ResponseService.Errors.Add("Order Has Been Ordered!");
                return;
            }
            //3-find order details
            OrderDetails orderDetails = null;

            orderDetails = CreateOrderDetailsIfNotExist(order, user);

            //4-find item

            item = ItemService.GetByGuid(itemId);

            if (item == null)
            {
                ResponseService.Status = false;
                ResponseService.Errors.Add("User Not Found");
                return;
            }

            //5-create item details
            ItemDetails itemDetails = new ItemDetails()
            {
                OrderDetailsId = orderDetails.Id,
                ItemId         = item.ElementId,
                Amount         = amount,
                Notes          = notes
            };

            UnitOfWork.ItemDetailsRepository.Create(itemDetails);

            if (UnitOfWork.Save() > 0)
            {
                ResponseService.Status = true;
                ResponseService.Success.Add("Order Created Successfully");
            }
            else
            {
                ResponseService.Status = false;
                ResponseService.Errors.Add("Server Error");
            }
        }