public static void AddRight(User user, RoleTemplate r, Function f) { try { DAL dalDataContext = new DAL(); Table<RightTemplate> rights = dalDataContext.rightTemplate; RightTemplate creatingright = new RightTemplate(r.RoleTemplateID, f.FunctionEnum); rights.InsertOnSubmit(creatingright); rights.Context.SubmitChanges(); } catch { throw new FaultException<SException>(new SException(), new FaultReason("An Error occured While Adding New Right Template, Please Try Again!")); } }
public static void DeleteRight(User user, RightTemplate r) { //chk if user can do this anot try { DAL dalDataContext = new DAL(); RightTemplate matchedright = (from rights in dalDataContext.rightTemplate where rights.RoleTemplateID == r.RoleTemplateID && rights.FunctionEnum == r.FunctionEnum select rights).FirstOrDefault(); dalDataContext.rightTemplate.DeleteOnSubmit(matchedright); dalDataContext.SubmitChanges(); } catch { throw new FaultException<SException>(new SException(), new FaultReason("An Error occured While Deleting Right Template, Please Try Again!")); } }