private questStatus delete(FMSEntities dbContext, GroupId groupId)
        {
            // Initialize
            questStatus status = null;


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

                // Delete the record.
                dbContext.Groups.Remove(_group);
                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));
        }
        /*----------------------------------------------------------------------------------------------------------------------------------
        * Groups
        *---------------------------------------------------------------------------------------------------------------------------------*/
        private questStatus create(FMSEntities dbContext, Group group, out GroupId groupId)
        {
            // Initialize
            groupId = null;


            // Perform create
            try
            {
                Quest.Services.Dbio.FMS.Groups _group = new Quest.Services.Dbio.FMS.Groups();
                BufferMgr.TransferBuffer(group, _group);
                dbContext.Groups.Add(_group);
                dbContext.SaveChanges();
                if (_group.Id == 0)
                {
                    return(new questStatus(Severity.Error, "Group not created"));
                }
                groupId = new GroupId(_group.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, string groupname, out Group group)
        {
            // Initialize
            questStatus status = null;

            group = null;


            // Perform transaction read.
            Quest.Services.Dbio.FMS.Groups _group = null;
            status = read((FMSEntities)trans.DbContext, groupname, out _group);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            group = new Group();
            BufferMgr.TransferBuffer(_group, group);

            return(new questStatus(Severity.Success));
        }
        public questStatus Read(string groupname, out Group group)
        {
            // Initialize
            questStatus status = null;

            group = null;


            // Perform read
            using (FMSEntities dbContext = new FMSEntities())
            {
                Quest.Services.Dbio.FMS.Groups _group = null;
                status = read(dbContext, groupname, out _group);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
                group = new Group();
                BufferMgr.TransferBuffer(_group, group);
            }
            return(new questStatus(Severity.Success));
        }
        private questStatus read(FMSEntities dbContext, string groupname, out Quest.Services.Dbio.FMS.Groups group)
        {
            // Initialize
            group = null;


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