/// <summary> /// Update Employee Information /// </summary> /// <param name="Emp"></param> /// <returns></returns> public string Update_Employee(Menu menu) { if (menu != null && ModelState.IsValid) { using (webAppDbEntities Obj = new webAppDbEntities()) { var menu_ = Obj.Entry(menu); Menu EmpObj = Obj.Menus.Where(x => x.MenuId == menu.MenuId).FirstOrDefault(); EmpObj.MenuName = menu.MenuName; EmpObj.MenuIcon = menu.MenuIcon; EmpObj.Status = menu.Status; Obj.SaveChanges(); return("Menu Updated Successfully"); } } else { return("Menu Not Updated! Try Again"); } }
/// <summary> /// Delete Employee Information /// </summary> /// <param name="Emp"></param> /// <returns></returns> public string Delete_Employee(Menu menu) { if (menu != null) { using (webAppDbEntities Obj = new webAppDbEntities()) { var menu_ = Obj.Entry(menu); if (menu_.State == EntityState.Detached) { Obj.Menus.Attach(menu); Obj.Menus.Remove(menu); } Obj.SaveChanges(); return("Menu Deleted Successfully"); } } else { return("Employee Not Deleted! Try Again"); } }