public string Edit(AclGroup acl) { string msg; try { if (ModelState.IsValid) { openMapDB.Entry(acl).State = EntityState.Modified; openMapDB.SaveChanges(); msg = "Berhasil mengubah data AclGroup."; } else { msg = "Validasi data mengalami kegagalan."; } } catch (Exception e) { msg = "Terjadi kesalahan " + e.Message; } return msg; }
public JsonResult SetAclGroupByGroupAndAction(int GroupID,int ActionID, int Value) { string status = ""; if(Value == 1) { AclGroup aclGroup = new AclGroup(); aclGroup.GroupID = GroupID; aclGroup.ActionID = ActionID; openMapDB.AclGroup.Add(aclGroup); openMapDB.SaveChanges(); status = "existing record created"; } else { try { IEnumerable<AclGroup> aclGroup = openMapDB.AclGroup.Where(a => a.GroupID == GroupID && a.ActionID == ActionID).ToList(); if(aclGroup != null) { foreach (AclGroup aclGrp in aclGroup) { openMapDB.AclGroup.Remove(aclGrp); openMapDB.SaveChanges(); } status = "existing data removed"; } } catch(Exception e) { status = "unexistent record"; } } return Json(new{status = status}, JsonRequestBehavior.AllowGet); }