public void Add(RoleRights rrObj) { rrObj.CanDelete = true;//double-make-sure that new record is not marked as undeletable MasterRole rObj = GetRoleObj(rrObj); dbc.MasterRoles.InsertOnSubmit(rObj); //dbc.SubmitChanges(); }
public void Delete(RoleRights rObj) { dbc.MasterRoles.DeleteOnSubmit(dbc.MasterRoles.Single(r => r.CanDelete && r.ID == rObj.ID)); //dbc.SubmitChanges(); }
public void Update(RoleRights rrObj) { if (rrObj.ID <= Defaults.Integer) // Insert return;//HT:SPECIAL CASE: W've handled Add separately so we skip //Add(rrObj); else // Update { MasterRole rObj = GetRoleObj(rrObj); dbc.MasterRoles.Attach(rObj); dbc.Refresh(System.Data.Linq.RefreshMode.KeepCurrentValues, rObj); //Optimistic-concurrency (simplest solution) //dbc.SubmitChanges(); } }
public MasterRole GetRoleObj(RoleRights rrObj) { return new MasterRole() { ID = rrObj.ID, Title = rrObj.Title, SortOrder = rrObj.SortOrder, LastModifiedBy = _SessionUsr.ID, LastModifiedDate = DateTime.Now, ManageRole = rrObj.RoleData.ManageRole, DeleteClaim = rrObj.RoleData.DeleteClaim, ManageUser = rrObj.RoleData.ManageUser, ManageMaster = rrObj.RoleData.ManageMaster, ViewActivity = rrObj.RoleData.ViewActivity, ManageSetting = rrObj.RoleData.ManageSetting, ArchiveClaim = rrObj.RoleData.ArchiveClaim, CanDelete = rrObj.CanDelete, OrgTypeId = rrObj.RoleData.OrgTypeId }; }