Пример #1
0
        public async Task <IActionResult> Edit(int id, [Bind("SupplierID,SupName,SupPno,SupEmail")] Supplier supplier)
        {
            if (id != supplier.SupplierID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(supplier);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SupplierExists(supplier.SupplierID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(supplier));
        }
Пример #2
0
        public async Task <IActionResult> Edit(int id, [Bind("CategoryID,Name")] Category category)
        {
            if (id != category.CategoryID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(category);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CategoryExists(category.CategoryID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
Пример #3
0
        public async Task <IActionResult> Edit(int id, [Bind("OrderID,UserID,OrdDate,OrdStatus,OrdSDate,OrdCost")] Order order)
        {
            if (id != order.OrderID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(order);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrderExists(order.OrderID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserID"] = new SelectList(_context.Users, "UserID", "UserID", order.UserID);
            return(View(order));
        }
        public async Task <IActionResult> Edit(int id, [Bind("SouvenirID,Name,Description,SupplierID,CategoryID,Price,ImagePath")] Souvenir souvenir)
        {
            if (id != souvenir.SouvenirID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(souvenir);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SouvenirExists(souvenir.SouvenirID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryID"] = new SelectList(_context.Categories, "CategoryID", "Name", souvenir.CategoryID);
            ViewData["SupplierID"] = new SelectList(_context.Suppliers, "SupplierID", "Name", souvenir.SupplierID);
            return(View(souvenir));
        }
Пример #5
0
        public async Task <IActionResult> Edit(int id, User user)
        {
            if (id != user.UserID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    user.UsePassword = Crypto.Hash(user.UsePassword);
                    _context.Update(user);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserExists(user.UserID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Details)));
            }
            return(View(user));
        }
Пример #6
0
        public async Task <IActionResult> Edit(int id, [Bind("CustomerID,HomePhoneNumber,WorkPhoneNumber,MobilePhoneNumber,FirstMidName,LastName,Address,Email,Password")] Customer customer)
        {
            if (id != customer.CustomerID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(customer);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CustomerExists(customer.CustomerID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }
        public async Task <IActionResult> PayBill()
        {
            List <string> data   = new List <string>();
            List <int>    dataq  = new List <int>();
            List <int>    dataid = new List <int>();
            float         total  = 0;

            string dataAs = HttpContext.Session.GetString("QUALITYPRODUCT");

            data.AddRange(dataAs.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries));
            for (int i = 0; i < data.Count; i++)
            {
                dataq.Add(Convert.ToInt32(data[i].Split(new char[] { '/' }).Last()));
                dataid.Add(Convert.ToInt32(data[i].Split(new char[] { '/' }).First()));
                //calculate total price
                total += dataq[i] * _context.Souvenirs.Where(so => so.SouvenirID == dataid[i]).Select(p => p.SouPrice).First();
            }

            var    s     = _context.Souvenirs.Where(so => dataid.Contains(so.SouvenirID));
            string id    = HttpContext.Session.GetString("QUALITYIDSTRING");
            var    order = new Order();

            order.UserID    = Convert.ToInt32(id);
            order.OrdDate   = DateTime.Now;
            order.OrdStatus = "Waiting";
            order.OrdCost   = total;
            _context.Add(order);
            await _context.SaveChangesAsync();

            for (int i = 0; i < dataq.Count; i++)
            {
                var souvenir = _context.Souvenirs.Where(so => so.SouvenirID == dataid[i]).First();
                souvenir.SouQuantity = souvenir.SouQuantity - dataq[i];

                var orderitem = new OrderItem();
                orderitem.OrderID    = order.OrderID;
                orderitem.SouvenirID = dataid[i];
                orderitem.OrdItemQ   = dataq[i];
                _context.Add(orderitem);
                _context.Update(souvenir);
            }
            await _context.SaveChangesAsync();



            HttpContext.Session.SetString("QUALITYPRODUCT", "");
            HttpContext.Session.SetInt32("CartCount", 0);
            return(View("~/Views/Cart/PayBill.cshtml"));
        }
        public async Task <IActionResult> Edit(int id, EditSouvenir souvenir)
        {
            if (id != souvenir.SouvenirID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var sou = new Souvenir();
                    using (var ms = new MemoryStream())
                    {
                        await souvenir.image.CopyToAsync(ms);

                        sou.SouvenirID     = souvenir.SouvenirID;
                        sou.SouImage       = ms.ToArray();
                        sou.SouQuantity    = souvenir.SouQuantity;
                        sou.SouDescription = souvenir.SouDescription;
                        sou.SouName        = souvenir.SouName;
                        sou.SouPrice       = souvenir.SouPrice;
                        sou.SupplierID     = souvenir.SupplierID;
                        sou.CategoryID     = souvenir.CategoryID;
                    }
                    _context.Update(sou);
                    await _context.SaveChangesAsync();
                }

                catch (DbUpdateConcurrencyException)
                {
                    if (!SouvenirExists(souvenir.SouvenirID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryID"] = new SelectList(_context.Categories, "CategoryID", "CategoryID", souvenir.CategoryID);
            ViewData["SupplierID"] = new SelectList(_context.Suppliers, "SupplierID", "SupplierID", souvenir.SupplierID);
            return(View(souvenir));
        }