public void Delete(int id) { using (var db = new HoGameEISContext()) { GroupBuySubItem _subItem = db.GroupBuySubItems.Where(o => o.SubItemId == id).FirstOrDefault(); db.Entry(_subItem).State = System.Data.Entity.EntityState.Deleted; List<GroupBuySubscriber> _subscribers = db.GroupBuySubscribers.Where(s => s.SubItemId==id).ToList(); foreach (GroupBuySubscriber subscriber in _subscribers) { db.Entry(subscriber).State = System.Data.Entity.EntityState.Deleted; } db.SaveChanges(); } }
public void Put(int id, [FromBody]GroupBuyStoreItem item) { using (var db = new HoGameEISContext()) { GroupBuyStoreItem _item = db.GroupBuyStoreItems.Where(o => o.ItemId == id).FirstOrDefault(); _item.ItemName = item.ItemName; db.Entry(_item).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } }
public void Put(int id, [FromBody]GroupBuyStoreSubItem item) { if (String.IsNullOrEmpty(item.Action)) { return; } using (var db = new HoGameEISContext()) { GroupBuyStoreSubItem _item = db.GroupBuyStoreSubItems.Where(o => o.SubItemId == id).FirstOrDefault(); if (item.Action == "SubItemName") { _item.SubItemName = item.SubItemName; } if (item.Action == "Price") { _item.Price = item.Price; } db.Entry(_item).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } }
public ActionResult ChangePassword(FormCollection formCollection) { string password = formCollection["password"]; Employee emp; using (var db = new HoGameEISContext()) { int employeeId = CurrentUser().EmployeeId; emp = db.Employees.Where(o => o.EmployeeId == employeeId).FirstOrDefault<Employee>(); if (emp != null) { emp.Password = password; db.Entry(emp).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } } return RedirectToAction("Logout"); }
public void Delete(int id) { GroupBuyStoreMenuImage image = new GroupBuyStoreMenuImage(); using (var db = new HoGameEISContext()) { image = db.GroupBuyStoreMenuImages.Where(o => o.ImageId == id).FirstOrDefault<GroupBuyStoreMenuImage>(); } using (var db = new HoGameEISContext()) { db.Entry(image).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); } deleteblobFile(image.ImageUrl); }
public ActionResult StoreManagementEdit(FormCollection formData, int id = -1) { GroupBuyStore groupBuyStore; if (id != -1) { using (var db = new HoGameEISContext()) { groupBuyStore = db.GroupBuyStores.Where(o => o.StoreId == id).FirstOrDefault<GroupBuyStore>(); if (groupBuyStore != null) { groupBuyStore.StoreName = formData["StoreName"]; groupBuyStore.Address = formData["Address"]; groupBuyStore.Tel = formData["Tel"]; groupBuyStore.Category = formData["Category"]; groupBuyStore.Memo = formData["Memo"]; db.Entry(groupBuyStore).State = System.Data.Entity.EntityState.Modified; //4. call SaveChanges db.SaveChanges(); } } } else { using (var db = new HoGameEISContext()) { groupBuyStore = new GroupBuyStore() { StoreName = formData["StoreName"], Address = formData["Address"], Tel = formData["Tel"], Category = formData["Category"], Memo = formData["Memo"] }; db.GroupBuyStores.Add(groupBuyStore); db.SaveChanges(); } } return RedirectToAction("StoreManagement", "GroupBuy"); }
public void GroupbuyEndTime(int GroupBuyId, GroupBuy input) { GroupBuy groupBuy; using (var db = new HoGameEISContext()) { groupBuy = db.GroupBuys.Where(o => o.GroupBuyId == GroupBuyId).FirstOrDefault<GroupBuy>(); if (groupBuy != null) { groupBuy.EndTime = input.EndTime; db.Entry(groupBuy).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } } }