Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Naam,Formaat")] Product product)
        {
            if (id != product.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(product);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductExists(product.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(product));
        }
Ejemplo n.º 2
0
        public OrderOut SetSeller(string orderId, string sellerId)
        {
            var order = ffContext.Orders.FirstOrDefault(ord => ord.Id == orderId);

            if (order == null)
            {
                throw new ArgumentException("order");
            }

            var seller = ffContext.Users.FirstOrDefault(usr => usr.Id == sellerId);

            if (seller == null)
            {
                throw new ArgumentException("seller");
            }

            order.Seller = seller;
            order.Status = "В работе";

            ffContext.Update(order);
            ffContext.SaveChanges();

            return(Get(order.Id));
        }
Ejemplo n.º 3
0
        public ServiceResult <StoreInvoicing> AddstoreInvoicing(string productId, int customerId)
        {
            var errors = new List <string>();

            if (errors.Any())
            {
                return(ServiceResult <StoreInvoicing> .Failed(errors));
            }
            StoreInvoicing storeInvoicing = _context.StoreInvoicings.SingleOrDefault(s => s.CustomerId == 1 && s.StoreInvoicingStatus != 1);

            if (storeInvoicing == null)
            {
                storeInvoicing = new StoreInvoicing
                {
                    CustomerId = 1,//customerId,
                    //StoreInvoicingCreateDate = DateTime.Now,
                    StoreInvoicingStatus = 0,
                    IsDelete             = false
                };
                _context.StoreInvoicings.Add(storeInvoicing);
                _context.StoreInvoicingDetails.Add(new StoreInvoicingDetails()
                {
                    InvoicingId               = storeInvoicing.InvoicingDetailId,
                    ProductId                 = 1,//productId,
                    CurrentPrice              = _context.Products.Find(productId).UnitPrice,
                    Qty                       = _context.Products.Find(productId).NumberOfOrders,
                    TotalAmount               = 0,
                    LaborCustomerItem         = 5000,
                    InvoicingDetailCreateDate = DateTime.Now,
                    InvoicingDetailStatus     = 1,
                    IsDelete                  = false
                });
                var result = _context.SaveChanges();

                if (result > 0)
                {
                    return(ServiceResult <StoreInvoicing> .Succeed(storeInvoicing));
                }
            }
            else
            {
                var details = _context.StoreInvoicingDetails.SingleOrDefault(s =>
                                                                             s.InvoicingId == storeInvoicing.InvoicingDetailId &&
                                                                             s.ProductId == 1 /*productId*/);
                if (details == null)
                {
                    _context.StoreInvoicingDetails.Add(new StoreInvoicingDetails()
                    {
                        InvoicingId               = storeInvoicing.InvoicingDetailId,
                        ProductId                 = 1,//productId,
                        CurrentPrice              = _context.Products.Find(productId).UnitPrice,
                        Qty                       = _context.Products.Find(productId).NumberOfOrders,
                        TotalAmount               = 0,
                        LaborCustomerItem         = 5000,
                        InvoicingDetailCreateDate = DateTime.Now,
                        InvoicingDetailStatus     = 1,
                        IsDelete                  = false
                    });
                }
                else
                {
                    details.Qty += 1;
                    _context.Update(details);
                }

                var result = _context.SaveChanges();
                UpdateTotalAmount(storeInvoicing.InvoicingDetailId);
                if (result > 0)
                {
                    return(ServiceResult <StoreInvoicing> .Succeed(storeInvoicing));
                }
            }


            return(ServiceResult <StoreInvoicing> .Failed(new List <string> {
                "Data not inserted!!!"
            }));
        }