예제 #1
0
        public ProductsGroup GetGemachProductsGroupByGemachIdAndProductsGroupId(int gemachid, int productsgroupid)
        {
            Gemach        gemach = gemaches.Find(g => g.GemachId == gemachid);
            ProductsGroup retVal = gemach.GemachProductsGroups.Find(gpg => gpg.ProductsGroupId == productsgroupid);

            return(retVal);
        }
예제 #2
0
        public Product GetGemachProductsGroupProductByGemachIdAndProductsGroupIdAndProductId(int gemachid, int productsgroupid, int productid)
        {
            Gemach        gemach        = gemaches.Find(g => g.GemachId == gemachid);
            ProductsGroup productsGroup = gemach.GemachProductsGroups.Find(gpg => gpg.ProductsGroupId == productsgroupid);
            Product       retVal        = productsGroup.ProductGroupProducts.Find(gpgp => gpgp.ProductId == productid);

            return(retVal);
        }
예제 #3
0
        public IEnumerable <Product> GetGemachProductsGroupsProductsByGemachIdAndProductsGroup(int gemachid, int productsgroupid)
        {
            Gemach                gemach        = gemaches.Find(g => g.GemachId == gemachid);
            ProductsGroup         productsGroup = gemach.GemachProductsGroups.Find(gpg => gpg.ProductsGroupId == productsgroupid);
            IEnumerable <Product> retVal        = productsGroup.ProductGroupProducts;

            return(retVal);
        }
예제 #4
0
        public async Task <ApiResult <OrderDto> > GetOrderAsync(string orderId)
        {
            var hasPaid      = _context.ReceiptVouchers.Where(x => x.OrderId == orderId).Sum(x => x.Received);
            var orderDetails = await(from o in _context.Orders
                                     join customer in _context.Customers on o.CustomerId equals customer.Id
                                     into CustomerGroup
                                     from c in CustomerGroup.DefaultIfEmpty()
                                     join ts in _context.TransactionStatuses on o.TransactionStatusId equals ts.Id
                                     join ps in _context.PaymentStatuses on o.PaymentStatusId equals ps.Id
                                     join branch in _context.Branches on o.BranchId equals branch.Id
                                     into BranchGroup
                                     from b in BranchGroup.DefaultIfEmpty()
                                     join employee in _context.Employees on o.EmployeeId equals employee.Id
                                     into EmployeesGroup
                                     from e in EmployeesGroup.DefaultIfEmpty()
                                     where o.Id == orderId
                                     select new OrderDto()
            {
                Id                    = o.Id,
                BranchName            = b.Name,
                CustomerName          = string.IsNullOrEmpty(c.Name)?o.CustomerName:c.Name,
                DateCreated           = o.DateCreated,
                Description           = o.Description,
                DiscountDescription   = o.DiscountDescription,
                DiscountType          = o.DiscountType,
                DiscountValue         = o.DiscountValue,
                EmployeeName          = e.Name,
                CustomerAddress       = o.CustomerAddress,
                CustomerPhone         = o.CustomerPhone,
                PaymentStatusName     = ps.Name,
                TransactionStatusName = ts.Name,
                OrderDetailsDtos      = (from od in _context.OrderDetails
                                         join product in _context.Products on od.ProductId equals product.Id
                                         into ProductsGroup
                                         from p in ProductsGroup.DefaultIfEmpty()
                                         where od.OrderId == o.Id
                                         select new OrderDetailsDto()
                {
                    Id = od.Id,
                    ProductId = od.ProductId,
                    Quantity = od.Quantity,
                    ServiceName = od.ServiceName,
                    UnitPrice = od.UnitPrice,
                    ProductName = p.Name
                }).ToList(),
                TotalAmount = o.TotalAmount,
                RestAmount  = o.TotalAmount - hasPaid,
                CustomerId  = c.Id
            }).SingleOrDefaultAsync();

            if (orderDetails == null)
            {
                return(new ApiResult <OrderDto>(HttpStatusCode.NotFound, $"Không tìm thấy đơn hàng có mã: {orderId}"));
            }
            return(new ApiResult <OrderDto>(HttpStatusCode.OK, orderDetails));
        }
예제 #5
0
        public int InsertProductsGroup(ProductsGroup productsGroup)
        {
            if (productsGroup == null)
            {
                throw new ArgumentNullException(nameof(productsGroup));
            }

            dbContext.ProductsGroups.Add(productsGroup);
            dbContext.SaveChanges();

            return(productsGroup.Id);
        }
예제 #6
0
        public bool UpdateProductsGroup(ProductsGroup entity)
        {
            var productsGroup = dbContext.ProductsGroups.Find(entity.Id);

            if (productsGroup == null)
            {
                throw new ArgumentNullException(nameof(productsGroup));
            }

            productsGroup.Published = entity.Published;
            productsGroup.Title     = entity.Title;
            productsGroup.NumberOfProductsPerItem = entity.NumberOfProductsPerItem;
            productsGroup.DisplayOrder            = entity.DisplayOrder;

            dbContext.SaveChanges();
            return(true);
        }
 public ActionResult Create(ProductsGroup productsGroup)
 {
     if (ModelState.IsValid)
     {
         var productsGroupDao = new ProductsGroupDao();
         int Id = productsGroupDao.InsertProductsGroup(productsGroup);
         if (Id > 0)
         {
             SetNotification("Thêm mới ProductGroups thành công", "");
             return(RedirectToAction("Index", "ProductsGroup"));
         }
         else
         {
             ModelState.AddModelError("", "Thêm mới ProductsGroup không thành công");
         }
     }
     return(View());
 }
        public ActionResult Edit(ProductsGroup productsGroup)
        {
            if (productsGroup == null)
            {
                throw new ArgumentNullException(nameof(productsGroup));
            }

            var result = new ProductsGroupDao().UpdateProductsGroup(productsGroup);

            if (result)
            {
                SetNotification("Cập nhật ProductGroups thành công", "");
                return(RedirectToAction("Index", "ProductsGroup"));
            }
            else
            {
                ModelState.AddModelError("", "Cập nhật ProductsGroup không thành công");
            }
            return(View());
        }