Пример #1
0
        public static RoleTemplate AddRoleTemplate(Events evnt, string RoleTemplatePost, string RoleTemplateDescription, DAL dalDataContext)
        {
            try
            {

                Table<RoleTemplate> roles = dalDataContext.roleTemplate;
                RoleTemplate creatingRole;
                //if(e == null)
                creatingRole = new RoleTemplate(RoleTemplatePost, RoleTemplateDescription, evnt);
                //else
                //    creatingRole = new RoleTemplate(RoleTemplatePost, RoleTemplateDescription, evnt.EventID);

                roles.InsertOnSubmit(creatingRole);

                roles.Context.SubmitChanges();

                return creatingRole;

            }
            catch
            {
                throw new FaultException<SException>(new SException(),
                   new FaultReason("An Error occured While Adding New Role Template, Please Try Again!"));
            }
        }
Пример #2
0
        public static void AddRight(User user, List<RightTemplate> r, RoleTemplate role)
        {
            //chk if user can do this anot
            try
            {
                DAL dalDataContext = new DAL();
                Table<RightTemplate> rights = dalDataContext.rightTemplate;

                //using (TransactionScope tScope = new TransactionScope(TransactionScopeOption.Required))
                //{
                for (int i = 0; i < r.Count; i++)
                {
                    r[i].RoleTemplateID = role.RoleTemplateID;
                    rights.InsertOnSubmit(r[i]);
                }

                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 Template, Please Try Again!"));
            }
        }
Пример #3
0
        public static RoleTemplate AddRoleTemplate(User user, RoleTemplate r)
        {
            //chk if user can do this anot

            try
            {
                DAL dalDataContext = new DAL();
                Table<RoleTemplate> roles = dalDataContext.roleTemplate;
                roles.InsertOnSubmit(r);
                roles.Context.SubmitChanges();
                return r;
            }
            catch
            {
                throw new FaultException<SException>(new SException(),
                   new FaultReason("An Error occured While Adding New Role Template, Please Try Again!"));
            }
        }
Пример #4
0
        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!"));
            }
        }
Пример #5
0
        public static RoleTemplate AddRoleTemplate(User user, int EventID, string RoleTemplatePost, string RoleTemplateDescription)
        {
            try
            {
                DAL dalDataContext = new DAL();
                Table<RoleTemplate> roles = dalDataContext.roleTemplate;

                RoleTemplate creatingRole = new RoleTemplate(RoleTemplatePost, RoleTemplateDescription, EventController.GetEvent(EventID));

                roles.InsertOnSubmit(creatingRole);

                roles.Context.SubmitChanges();

                return creatingRole;

            }
            catch
            {
                throw new FaultException<SException>(new SException(),
                   new FaultReason("An Error occured While Adding New Role Template, Please Try Again!"));
            }
        }