Example #1
0
        public IHttpActionResult PutTable(int id, Table table)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != table.EmployeeID)
            {
                return(BadRequest());
            }

            db.Entry(table).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TableExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #2
0
        public ActionResult Create([Bind(Include = "id,Name,AddressLine")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                db.Employees.Add(employee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(employee));
        }
Example #3
0
        public ActionResult DeleteRole(int id = 0)
        {
            try
            {
                var deleteUserRole = _Context.UserRoles.Where(x => x.FK_RoleID == id).Select(x => x).ToList();
                foreach (var item in deleteUserRole)
                {
                    _Context.UserRoles.Remove(item);
                }
                _Context.SaveChanges();
            }
            catch { }

            try
            {
                var deleteUserRolePrivilege = _Context.UserRolePrivileges.Where(x => x.FK_RoleID == id).Select(x => x).ToList();
                foreach (var item in deleteUserRolePrivilege)
                {
                    _Context.UserRolePrivileges.Remove(item);
                }
                _Context.SaveChanges();
            }
            catch { }

            var deleteRole = _Context.Roles.Where(x => x.PK_RoleID == id).Select(x => x).SingleOrDefault();

            _Context.Roles.Remove(deleteRole);
            _Context.SaveChanges();

            return(RedirectToAction("RoleList"));
        }