Example #1
0
        public static void AddRight(User user, Role r, EnumFunctions f)
        {
            try
            {
                DAL dalDataContext = new DAL();
                Table<Right> rights = dalDataContext.rights;

                Right creatingright = new Right(r.RoleID, f);
                //using (TransactionScope tScope = new TransactionScope(TransactionScopeOption.Required))
                //{
                rights.InsertOnSubmit(creatingright);
                rights.Context.SubmitChanges();
                //use this to Create rights //if error need to delete it
                //       throw new Exception();
                //tScope.Complete();
                // }
            }
            catch
            {
                throw new FaultException<SException>(new SException(),
                   new FaultReason("An Error occured While Adding New Right, Please Try Again!"));
            }
        }
Example #2
0
        public static void DeleteRight(User user, Right r)
        {
            //chk if user can do this anot
            try
            {
                DAL dalDataContext = new DAL();
                Right matchedright = (from rights in dalDataContext.rights
                                      where rights.RoleID == r.RoleID &&
                                      rights.FunctionEnum == r.FunctionEnum
                                      select rights).FirstOrDefault();

                dalDataContext.rights.DeleteOnSubmit(matchedright);
                dalDataContext.SubmitChanges();
            }
            catch
            {
                throw new FaultException<SException>(new SException(),
                   new FaultReason("An Error occured While Deleting Right, Please Try Again!"));
            }
        }