Beispiel #1
0
        public void payment(int tableId)
        {
            CounterModel model        = new CounterModel();
            var          currentTable = entity.Tables.SingleOrDefault(table => table.Number == tableId);
            var          currentInvoice
                = entity.Invoices.SingleOrDefault(invoice => invoice.Number == tableId && !invoice.Status);

            if (currentInvoice == null)
            {
                model.TableList = entity.Tables.ToList();
                RedirectToAction("Index", model);
            }
            if (currentInvoice != null)
            {
                currentTable.Status = false;
                var invoiceDetail = entity.InvoiceDetails.Where(i => i.ID_Invoice == currentInvoice.ID_Invoice).ToList();
                foreach (var element in invoiceDetail)
                {
                    var item = element;
                    entity.Entry(item).State = System.Data.Entity.EntityState.Deleted;
                }
                entity.Entry(currentInvoice).State = System.Data.Entity.EntityState.Deleted;
                entity.SaveChanges();
            }
        }
        public ActionResult Edit(Restaurant restaurant)
        {
            if (ModelState.IsValid)
            {
                _db.Entry(restaurant).State = System.Data.Entity.EntityState.Modified;
                _db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(restaurant));
        }
Beispiel #3
0
 public ActionResult Edit([Bind(Include = "RestaurantId,Name, RestaurantAddress")] Restaurant restaurant)
 {
     if (ModelState.IsValid)
     {
         db.Entry(restaurant).State = EntityState.Modified;
         db.SaveChanges();
         db.Entry(restaurant.RestaurantAddress).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.RestaurantId = new SelectList(db.Addresses, "Id", "Street", restaurant.RestaurantId);
     return View(restaurant);
 }
        public async Task <IActionResult> PutOrderMaster(long id, OrderMaster orderMaster)
        {
            if (id != orderMaster.OrderMasterId)
            {
                return(BadRequest());
            }

            _context.Entry(orderMaster).State = EntityState.Modified;

            // existing food items  & newly added food items
            foreach (OrderDetail item in orderMaster.OrderDetails)
            {
                if (item.OrderDetailId == 0)
                {
                    _context.OrderDetails.Add(item);
                }
                else
                {
                    _context.Entry(item).State = EntityState.Modified;
                }
            }
            // deleted food item
            if (orderMaster.DeletedOrderItemIds != null)
            {
                foreach (var i in orderMaster.DeletedOrderItemIds.Split(',').Where(x => x != ""))
                {
                    OrderDetail y = _context.OrderDetails.Find(Convert.ToInt32(i));
                    _context.OrderDetails.Remove(y);
                }
            }

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OrderMasterExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #5
0
        public async Task <IActionResult> PutOrderMaster(long id, OrderMaster orderMaster)
        {
            if (id != orderMaster.OrderMasterId)
            {
                return(BadRequest());
            }

            _context.Entry(orderMaster).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OrderMasterExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutRestaurant([FromRoute] int id, [FromBody] Restaurant restaurant)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != restaurant.Id)
            {
                return(BadRequest());
            }

            _context.Entry(restaurant).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RestaurantExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #7
0
        public async Task <IActionResult> PutCommandeM(long id, CommandeM commandeM)
        {
            if (id != commandeM.CommandeMId)
            {
                return(BadRequest());
            }

            _context.Entry(commandeM).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CommandeMExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #8
0
        public async Task <IActionResult> PutCustomer(int id, Customer customer)
        {
            if (id != customer.CustomerId)
            {
                return(BadRequest());
            }

            _context.Entry(customer).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CustomerExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #9
0
        public async System.Threading.Tasks.Task <T> Update(T entity)
        {
            _ctx.Entry(entity).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            await _ctx.SaveChangesAsync();

            return(entity);
        }
        public async Task <IActionResult> PutFoodItem(int id, FoodItem foodItem)
        {
            if (id != foodItem.FoodItemId)
            {
                return(BadRequest());
            }

            _context.Entry(foodItem).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FoodItemExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task<IActionResult> PutRestaurant(int id, Restaurant restaurant)
        {
            if (id != restaurant.Id)
            {
                return BadRequest();
            }

            _context.Entry(restaurant).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RestaurantExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return NoContent();
        }
Beispiel #12
0
        public async Task SaveAsync(Restaurant restaurant)
        {
            var doesItExist = restaurant.ID == default(int);

            _context.Entry(restaurant).State = doesItExist ? EntityState.Added : EntityState.Modified;

            await _context.SaveChangesAsync();
        }
Beispiel #13
0
        public string Remove(string productId)
        {
            Product product = new Product();

            product.id = productId;
            dbContext.Entry(product).State = EntityState.Deleted;
            dbContext.SaveChanges();
            return(productId);
        }
Beispiel #14
0
        public string Remove(string userId)
        {
            User user = new User();

            user.id = userId;
            dbContext.Entry(user).State = EntityState.Deleted;
            dbContext.SaveChanges();
            return(userId);
        }
        public virtual void Delete(T entityToDelete)
        {
            if (_restaurantDbContext.Entry(entityToDelete).State == EntityState.Detached)
            {
                _entities.Attach(entityToDelete);
            }

            _entities.Remove(entityToDelete);
        }
 public ActionResult Edit(Restaurant restaurant)
 {
     if (ModelState.IsValid)
     {
         _db.Entry(restaurant).State = EntityState.Modified;
         _db.SaveChanges();
     }
     return(View(restaurant));
 }
Beispiel #17
0
        public int Remove(int id)
        {
            var invoiceDetails = new InvoiceDetail();

            invoiceDetails.id = id;
            dbContext.Entry(invoiceDetails).State = EntityState.Deleted;
            dbContext.SaveChanges();
            return(id);
        }
 public ActionResult DeleteUser(string username)
 {
     if (!username.Equals(""))
     {
         var currentUser = entity.Accounts.SingleOrDefault(u => u.Username == username);
         entity.Entry(currentUser).State = System.Data.Entity.EntityState.Deleted;
     }
     if (entity.SaveChanges() > 0)
     {
         AdminModel model    = new AdminModel();
         var        userList = entity.Accounts.ToList();
         var        roleList = entity.Roles.Where(role => role.ID_Role != "AD").ToList();
         model.UserList = userList;
         model.RoleList = roleList;
         return(View("UserManagement", model));
     }
     return(null);
 }
Beispiel #19
0
 public ActionResult Edit([Bind(Include = "Id,ReviewerName, Rating,Comment,DateRated, Restaurant_RestaurantId, ReviewerId ")] RestaurantReview restaurantReview)
 {
     if (ModelState.IsValid)
     {
         db.Entry(restaurantReview).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index", new { restId = restaurantReview.Restaurant_RestaurantId }));
     }
     return(View(restaurantReview));
 }
 public ActionResult Edit(Restaurant restaurant)
 {
     if (ModelState.IsValid)
     {
         _db.Entry(restaurant).State = EntityState.Modified; // Finding the state of the object (Has it changed?)
         _db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(restaurant));
 }
 public ActionResult Edit([Bind(Include = "WarehouseTypeId,WarehouseName,Description")] WarehouseType warehouseType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(warehouseType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(warehouseType));
 }
 public ActionResult Edit([Bind(Include = "Id,Name,Description")] FoodCategory foodCategory)
 {
     if (ModelState.IsValid)
     {
         db.Entry(foodCategory).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(foodCategory));
 }
 public ActionResult Edit(Restaurant restaurant)
 {
     if (ModelState.IsValid)
     {
         _db.Entry(restaurant).State = EntityState.Modified;//look through table and see if it finds a match and update its state to modified. Makes the changes save to this entry.
         _db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(restaurant));//If not valid, return back to the edit view with the restaurant that THEY entered in the edit view again.
 }
 public ActionResult Edit(Restaurant item)
 {
     if (ModelState.IsValid)
     {
         _ctx.Entry(item).State = EntityState.Modified;
         _ctx.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(item));
 }
Beispiel #25
0
 public ActionResult Edit([Bind(Include = "SupplierTypeId,SupplierName,Description,Status")] SupplierType supplierType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(supplierType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(supplierType));
 }
Beispiel #26
0
 public ActionResult Edit([Bind(Include = "ExportImportTypeId,TypeName,Description")] ExportImportType exportImportType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(exportImportType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(exportImportType));
 }
Beispiel #27
0
 public ActionResult Edit(Restaurant restuarant)
 {
     if (ModelState.IsValid)
     {
         _db.Entry(restuarant).State = EntityState.Modified; // Access the state property find entry min 27:30 in video ... apply only modied rows in database
         _db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(restuarant));
 }
Beispiel #28
0
 public ActionResult Edit(Restaurant restaurant)
 {
     if (ModelState.IsValid)
     {
         _db.Entry(restaurant).State = EntityState.Modified; //Find entry on the table and tell it its been modified
         _db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(restaurant));
 }
Beispiel #29
0
 public ActionResult Edit(Restaurant restaurant)
 {
     if (ModelState.IsValid)
     {
         _restaurantDb.Entry(restaurant).State = EntityState.Modified; //grabbing model, and states changes and updates??
         _restaurantDb.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(restaurant));
 }
 public ActionResult Edit([Bind(Include = "SupplierId,Name,Address,Phone,Email,SupplierTypeId,Status")] Supplier supplier)
 {
     if (ModelState.IsValid)
     {
         db.Entry(supplier).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.SupplierTypeId = new SelectList(db.SupplierTypes, "SupplierTypeId", "SupplierName", supplier.SupplierTypeId);
     return(View(supplier));
 }