private questStatus delete(FMSEntities dbContext, GroupUserId groupUserId)
        {
            // Initialize
            questStatus status = null;


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

                // Delete the record.
                dbContext.GroupUsers.Remove(_groupUser);
                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));
        }
        /*----------------------------------------------------------------------------------------------------------------------------------
        * GroupUsers
        *---------------------------------------------------------------------------------------------------------------------------------*/
        private questStatus create(FMSEntities dbContext, GroupUser groupUser, out GroupUserId groupUserId)
        {
            // Initialize
            groupUserId = null;


            // Perform create
            try
            {
                Quest.Services.Dbio.FMS.GroupUsers _groupUser = new Quest.Services.Dbio.FMS.GroupUsers();
                _groupUser.GroupId = groupUser.Group.Id;
                _groupUser.UserId  = groupUser.User.Id;
                _groupUser.Created = DateTime.Now;
                dbContext.GroupUsers.Add(_groupUser);
                dbContext.SaveChanges();
                if (_groupUser.Id == 0)
                {
                    return(new questStatus(Severity.Error, "GroupUser not created"));
                }
                groupUserId = new GroupUserId(_groupUser.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));
        }
        public questStatus Read(DbMgrTransaction trans, GroupUserId groupUserId, out GroupUser groupUser)
        {
            // Initialize
            questStatus status = null;

            groupUser = null;


            // Perform read
            Quest.Services.Dbio.FMS.GroupUsers _groupUser = null;
            status = read((FMSEntities)trans.DbContext, groupUserId, out _groupUser);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            groupUser = new GroupUser();
            BufferMgr.TransferBuffer(_groupUser, groupUser);

            return(new questStatus(Severity.Success));
        }
        private questStatus read(FMSEntities dbContext, GroupUserId groupUserId, out Quest.Services.Dbio.FMS.GroupUsers groupUser)
        {
            // Initialize
            groupUser = null;


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