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


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

                // Delete the record.
                dbContext.UserPrivileges.Remove(_userPrivileges);
                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
        /*----------------------------------------------------------------------------------------------------------------------------------
        * UserPrivileges
        *---------------------------------------------------------------------------------------------------------------------------------*/
        private questStatus create(FMSEntities dbContext, UserPrivilege userPrivilege, out UserPrivilegeId userPrivilegeId)
        {
            // Initialize
            userPrivilegeId = null;


            // Perform create
            try
            {
                Quest.Services.Dbio.FMS.UserPrivileges _userPrivileges = new Quest.Services.Dbio.FMS.UserPrivileges();
                _userPrivileges.PrivilegeId = userPrivilege.Privilege.Id;
                _userPrivileges.UserId      = userPrivilege.User.Id;
                _userPrivileges.Created     = DateTime.Now;
                dbContext.UserPrivileges.Add(_userPrivileges);
                dbContext.SaveChanges();
                if (_userPrivileges.Id == 0)
                {
                    return(new questStatus(Severity.Error, "UserPrivilege not created"));
                }
                userPrivilegeId = new UserPrivilegeId(_userPrivileges.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, UserPrivilegeId userPrivilegeId, out UserPrivilege userPrivilege)
        {
            // Initialize
            questStatus status = null;

            userPrivilege = null;


            // Perform read
            Quest.Services.Dbio.FMS.UserPrivileges _userPrivileges = null;
            status = read((FMSEntities)trans.DbContext, userPrivilegeId, out _userPrivileges);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            userPrivilege = new UserPrivilege();
            BufferMgr.TransferBuffer(_userPrivileges, userPrivilege);

            return(new questStatus(Severity.Success));
        }
Esempio n. 4
0
        private questStatus read(FMSEntities dbContext, UserPrivilegeId userPrivilegeId, out Quest.Services.Dbio.FMS.UserPrivileges userPrivilege)
        {
            // Initialize
            userPrivilege = null;


            try
            {
                userPrivilege = dbContext.UserPrivileges.Where(r => r.Id == userPrivilegeId.Id).SingleOrDefault();
                if (userPrivilege == null)
                {
                    return(new questStatus(Severity.Warning, String.Format("WARNING: {0}.{1}: {2}",
                                                                           this.GetType().Name, MethodBase.GetCurrentMethod().Name,
                                                                           String.Format("Id {0} not found", userPrivilegeId.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));
        }