Esempio n. 1
0
        private questStatus delete(FMSEntities dbContext, PrivilegeId privilegeId)
        {
            // Initialize
            questStatus status = null;


            try
            {
                // Read the record.
                Quest.Services.Dbio.FMS.Privileges _privilege = null;
                status = read(dbContext, privilegeId, out _privilege);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }

                // Delete the record.
                dbContext.Privileges.Remove(_privilege);
                dbContext.SaveChanges();
            }
            catch (System.Exception ex)
            {
                return(new questStatus(Severity.Fatal, String.Format("EXCEPTION: {0}.{1}: {2}",
                                                                     this.GetType().Name, MethodBase.GetCurrentMethod().Name,
                                                                     ex.InnerException != null ? ex.InnerException.Message : ex.Message)));
            }
            return(new questStatus(Severity.Success));
        }
Esempio n. 2
0
        /*----------------------------------------------------------------------------------------------------------------------------------
        * Privileges
        *---------------------------------------------------------------------------------------------------------------------------------*/
        private questStatus create(FMSEntities dbContext, Privilege privilege, out PrivilegeId privilegeId)
        {
            // Initialize
            privilegeId = null;


            // Perform create
            try
            {
                Quest.Services.Dbio.FMS.Privileges _privilege = new Quest.Services.Dbio.FMS.Privileges();
                BufferMgr.TransferBuffer(privilege, _privilege);
                dbContext.Privileges.Add(_privilege);
                dbContext.SaveChanges();
                if (_privilege.Id == 0)
                {
                    return(new questStatus(Severity.Error, "Privilege not created"));
                }
                privilegeId = new PrivilegeId(_privilege.Id);
            }
            catch (System.Exception ex)
            {
                return(new questStatus(Severity.Fatal, String.Format("EXCEPTION: {0}.{1}: {2}",
                                                                     this.GetType().Name, MethodBase.GetCurrentMethod().Name,
                                                                     ex.InnerException != null ? ex.InnerException.Message : ex.Message)));
            }
            return(new questStatus(Severity.Success));
        }
Esempio n. 3
0
        public questStatus Read(DbMgrTransaction trans, string privilegename, out Privilege privilege)
        {
            // Initialize
            questStatus status = null;

            privilege = null;


            // Perform transaction read.
            Quest.Services.Dbio.FMS.Privileges _privilege = null;
            status = read((FMSEntities)trans.DbContext, privilegename, out _privilege);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            privilege = new Privilege();
            BufferMgr.TransferBuffer(_privilege, privilege);

            return(new questStatus(Severity.Success));
        }
Esempio n. 4
0
        public questStatus Read(string privilegename, out Privilege privilege)
        {
            // Initialize
            questStatus status = null;

            privilege = null;


            // Perform read
            using (FMSEntities dbContext = new FMSEntities())
            {
                Quest.Services.Dbio.FMS.Privileges _privilege = null;
                status = read(dbContext, privilegename, out _privilege);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
                privilege = new Privilege();
                BufferMgr.TransferBuffer(_privilege, privilege);
            }
            return(new questStatus(Severity.Success));
        }
Esempio n. 5
0
        private questStatus read(FMSEntities dbContext, string privilegename, out Quest.Services.Dbio.FMS.Privileges privilege)
        {
            // Initialize
            privilege = null;


            try
            {
                privilege = dbContext.Privileges.Where(r => r.Name == privilegename).SingleOrDefault();
                if (privilege == null)
                {
                    return(new questStatus(Severity.Error, String.Format("ERROR: {0}.{1}: {2}",
                                                                         this.GetType().Name, MethodBase.GetCurrentMethod().Name,
                                                                         String.Format("Id {0} not found", privilegename))));
                }
            }
            catch (System.Exception ex)
            {
                return(new questStatus(Severity.Fatal, String.Format("EXCEPTION: {0}.{1}: {2}",
                                                                     this.GetType().Name, MethodBase.GetCurrentMethod().Name,
                                                                     ex.InnerException != null ? ex.InnerException.Message : ex.Message)));
            }
            return(new questStatus(Severity.Success));
        }