Esempio n. 1
0
        public async Task <IActionResult> Edit(int id, [Bind("StoreId,StoreName,Phone,Email,Street,City,State,ZipCode")] Stores stores)
        {
            if (id != stores.StoreId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(stores);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StoresExists(stores.StoreId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(stores));
        }
Esempio n. 2
0
        public async Task <IActionResult> Edit(int id, [Bind("StaffId,FirstName,LastName,Email,Phone,Active,StoreId,ManagerId")] Staffs staffs)
        {
            if (id != staffs.StaffId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(staffs);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StaffsExists(staffs.StaffId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ManagerId"] = new SelectList(_context.Staffs, "StaffId", "Email", staffs.ManagerId);
            ViewData["StoreId"]   = new SelectList(_context.Stores, "StoreId", "StoreName", staffs.StoreId);
            return(View(staffs));
        }
Esempio n. 3
0
        public async Task <IActionResult> Edit(int id, [Bind("StoreId,ProductId,Quantity")] Stocks stocks)
        {
            if (id != stocks.StoreId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(stocks);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StocksExists(stocks.StoreId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductId"] = new SelectList(_context.Products, "ProductId", "ProductName", stocks.ProductId);
            ViewData["StoreId"]   = new SelectList(_context.Stores, "StoreId", "StoreName", stocks.StoreId);
            return(View(stocks));
        }
Esempio n. 4
0
        public ActionResult DeleteStor(int id)
        {
            // Yarın bitirilecek/referans tip değer tip bakılacak
            var entity = _context.Stores.Include("Orders").Include("Stocks").Include("Staff").FirstOrDefault(x => x.StoreId == id);

            if (entity == null)
            {
                return(NoContent());
            }
            foreach (var item in entity.Orders)
            {
                item.IsDeleted = true;
            }
            foreach (var item in entity.Stocks)
            {
                item.IsDeleted = true;
            }
            foreach (var item in entity.Staff)
            {
                item.IsDeleted = true;
            }
            entity.IsDeleted = true;
            _context.Update(entity);
            _context.SaveChanges();
            return(Ok());
        }
Esempio n. 5
0
        public async Task <IActionResult> Edit(int id, [Bind("OrderId,CustomerId,OrderStatus,OrderDate,RequiredDate,ShippedDate,StoreId,StaffId")] Orders orders)
        {
            if (id != orders.OrderId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(orders);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrdersExists(orders.OrderId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerId"] = new SelectList(_context.Customers, "CustomerId", "Email", orders.CustomerId);
            ViewData["StaffId"]    = new SelectList(_context.Staffs, "StaffId", "Email", orders.StaffId);
            ViewData["StoreId"]    = new SelectList(_context.Stores, "StoreId", "StoreName", orders.StoreId);
            return(View(orders));
        }
Esempio n. 6
0
        public async Task <IActionResult> Edit(int id, [Bind("ProductId,ProductName,BrandId,CategoryId,ModelYear,ListPrice")] Product product)
        {
            if (id != product.ProductId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(product);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductExists(product.ProductId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BrandId"]    = new SelectList(_context.Brands, "BrandId", "BrandName", product.BrandId);
            ViewData["CategoryId"] = new SelectList(_context.Categories, "CategoryId", "CategoryName", product.CategoryId);
            return(View(product));
        }
Esempio n. 7
0
        public ActionResult DeleteSto(int id)
        {
            var entity = _context.Stocks.FirstOrDefault(x => x.Quantity == id);

            if (entity == null)
            {
                return(NoContent());
            }
            entity.IsDeleted = true;
            _context.Update(entity);
            _context.SaveChanges();
            return(Ok());
        }
        public ActionResult DeleteOrIt(int id)
        {
            var entity = _context.OrderItems.FirstOrDefault(x => x.ItemId == id);

            if (entity == null)
            {
                return(NoContent());
            }
            entity.IsDeleted = true;
            _context.Update(entity);
            _context.SaveChanges();
            return(Ok());
        }
Esempio n. 9
0
        public ActionResult DeleteBrand(int id)
        {
            var entity = _context.Brands.Include("Products").FirstOrDefault(x => x.BrandId == id);

            if (entity == null)
            {
                return(NotFound("Kayıt bulunamadı."));
            }
            foreach (var item in entity.Products)
            {
                item.IsDeleted = true;
            }
            entity.IsDeleted = true;
            _context.Update(entity);
            _context.SaveChanges();
            return(Ok("Obje silinmiştir."));
        }
Esempio n. 10
0
        public ActionResult DeleteOr(int id)
        {
            var entity = _context.Orders.Include("OrderItems").FirstOrDefault(x => x.OrderId == id);

            if (entity == null)
            {
                return(NotFound());
            }
            foreach (var item in entity.OrderItems)
            {
                item.IsDeleted = true;
            }
            entity.IsDeleted = true;
            _context.Update(entity);
            _context.SaveChanges();
            return(Ok("Kayıt silinmiştir."));
        }
Esempio n. 11
0
        public ActionResult DeleteControl(int id)
        {
            var entity = _context.Categories.Include("Products").Include("OrderItems").FirstOrDefault(x => x.CategoryId == id);

            if (entity == null)
            {
                return(NotFound());
            }
            foreach (var item in entity.Products)
            {
                foreach (var order in item.OrderItems)
                {
                    order.IsDeleted = true;
                }
                item.IsDeleted = true;
            }
            entity.IsDeleted = true;
            _context.Update(entity);
            _context.SaveChanges();
            return(Ok("Id silinmiştir."));
        }
Esempio n. 12
0
        public ActionResult DeletePr(int id)
        {
            var entity = _context.Products.Include("OrderItems").Include("Stocks").FirstOrDefault(x => x.ProductId == id);

            if (entity == null)
            {
                return(NoContent());
            }
            foreach (var item in entity.OrderItems)
            {
                item.IsDeleted = true;
            }
            foreach (var item in entity.Stocks)
            {
                item.IsDeleted = true;
            }
            entity.IsDeleted = true;
            _context.Update(entity);
            _context.SaveChanges();
            return(Ok());
        }
Esempio n. 13
0
        public ActionResult DeleteSt(int id)
        {
            var entity = _context.Staffs.Include("InverseManager").Include("Orders").FirstOrDefault(x => x.StaffId == id);

            if (entity == null)
            {
                return(NoContent());
            }
            foreach (var item in entity.InverseManager)
            {
                item.IsDeleted = true;
            }
            foreach (var item in entity.Orders)
            {
                item.IsDeleted = true;
            }
            entity.IsDeleted = true;
            _context.Update(entity);
            _context.SaveChanges();
            return(Ok());
        }