Beispiel #1
0
        internal async Task <List <Group> > GetGroupsForProfileID(long ProfileID)
        {
            if (ProfileID == 0)
            {
                return(null);
            }

            var retGroups = new List <Group>();
            List <model.GroupMembership> eGrops = await _GroupRepository.GetGroupMembershipForProfile(ProfileID);

            if (eGrops != null && eGrops.Count > 0)
            {
                Group tmpGrp = null;

                entities.Group tmpEGrp = null;

                foreach (model.GroupMembership egrpmem in eGrops)
                {
                    tmpEGrp = _GroupStorageAccess.GetGroupByID(egrpmem.GroupID);
                    if (tmpEGrp != null)
                    {
                        tmpGrp             = Caster.MakeContractGroupLite(tmpEGrp);
                        tmpGrp.IsValidated = egrpmem.IsValidated;
                        retGroups.Add(tmpGrp);
                    }
                }
            }
            return(retGroups);
        }
Beispiel #2
0
 private string GetParentgroupName(List <entities.Group> entityGrps, entities.Group grp)
 {
     entities.Group entity =
         entityGrps.FirstOrDefault(x => grp.ParentGroupID.HasValue && x.GroupID == grp.ParentGroupID);
     if (entity != null)
     {
         return(entity.GroupName);
     }
     return(string.Empty);
 }
Beispiel #3
0
        public void EditGroup(Group grp, string partitionKey = null, string rowkey = null, bool isCreate = false)
        {
            LastUpdateDate = DateTime.UtcNow;

            var entityGrp = new entities.Group();

            entityGrp.GroupID       = Convert.ToInt16(grp.GroupID);
            entityGrp.GroupName     = grp.GroupName;
            entityGrp.EnrollmentKey = grp.EnrollmentKey;
            entityGrp.Email         = grp.Email;
            entityGrp.PhoneNumber   = grp.PhoneNumber;
            entityGrp.Location      = grp.GroupLocation;
            entityGrp.GroupType     = Convert.ToInt32(grp.Type);
            entityGrp.IsActive      = grp.IsActive;

            entityGrp.EnrollmentType            = Convert.ToInt32(grp.EnrollmentType);
            entityGrp.RowKey                    = grp.GroupID;
            entityGrp.PartitionKey              = grp.GroupLocation;
            entityGrp.ParentGroupID             = grp.ParentGroupID;
            entityGrp.NotifySubgroups           = grp.NotifySubgroups;
            entityGrp.SubGroupIdentificationKey = grp.SubGroupIdentificationKey;
            entityGrp.ShapeFileID               = grp.ShapeFileID;
            entityGrp.GeoLocation               = grp.GeoLocation;
            entityGrp.ShowIncidents             = grp.ShowIncidents;

            var _GroupStorageAccess = new GroupStorageAccess();

            _GroupStorageAccess.UpdateGroup(entityGrp);

            var entityAdmin = new entities.AdminUser();

            entityAdmin.AdminID              = Convert.ToInt16(grp.GroupID);
            entityAdmin.Email                = grp.Email;
            entityAdmin.GroupIDCSV           = grp.GroupID;
            entityAdmin.Name                 = grp.GroupName;
            entityAdmin.MobileNumber         = grp.PhoneNumber;
            entityAdmin.LiveUserID           = grp.LiveInfo.LiveID;
            entityAdmin.AllowGroupManagement = grp.AllowGroupManagement;
            entityAdmin.PartitionKey         = isCreate ? grp.GroupLocation : partitionKey;
            entityAdmin.RowKey               = isCreate ? Guid.NewGuid().ToString() : rowkey;

            var _MemberStorageAccess = new MemberStorageAccess();

            _MemberStorageAccess.SaveGroupAdmin(entityAdmin);
        }
Beispiel #4
0
        internal static contract.Group MakeContractGroupLite(entity.Group groupEntity)
        {
            if (groupEntity == null)
            {
                return(null);
            }

            var grp = new contract.Group();

            grp.GroupID        = groupEntity.GroupID.ToString();
            grp.GroupName      = groupEntity.GroupName;
            grp.GroupLocation  = groupEntity.Location;
            grp.EnrollmentType = (contract.Enrollment)groupEntity.EnrollmentType;
            grp.EnrollmentKey  = groupEntity.EnrollmentKey;
            grp.Type           = (contract.GroupType)groupEntity.GroupType;
            grp.IsActive       = groupEntity.IsActive;
            grp.Email          = groupEntity.Email;
            grp.PhoneNumber    = groupEntity.PhoneNumber; //TODO:Load Contact details from GroupContacts.
            grp.GeoLocation    = groupEntity.GeoLocation;
            grp.ShowIncidents  = groupEntity.ShowIncidents;
            return(grp);
        }
Beispiel #5
0
        //no change
        /// <summary>
        ///     Gets Amdin profile if the provide Live Unique user ID matches
        /// </summary>
        /// <param name="LUID">Live Unique User ID obtained by decrypting the JWT</param>
        /// <returns></returns>
        public Admin GetAdminProfile(string LUID)
        {
            var oResult = new Admin();

            if (string.IsNullOrEmpty(LUID))
            {
                utility.ResultsManager.AddResultInfo(oResult, ResultTypeEnum.Error, "The LiveMail provided was empty.");
                return(oResult);
            }

            if (_GroupStorageAccess == null)
            {
                _GroupStorageAccess = new GroupStorageAccess();
            }

            entities.AdminUser oAdmin = _GroupStorageAccess.GetAdminUser(LUID);

            if (oAdmin == null)
            {
                utility.ResultsManager.AddResultInfo(oResult, ResultTypeEnum.Error,
                                                     "The LiveMail did not yeild an admin.");
                return(oResult);
            }
            if (oAdmin.GroupIDCSV.Trim().Trim(',') == string.Empty)
            {
                oResult = Caster.MakeContractAdmin(oAdmin);
                utility.ResultsManager.AddResultInfo(oResult, ResultTypeEnum.Error,
                                                     "The admin is not associated to any groups.");
                return(oResult);
            }
            oResult = Caster.MakeContractAdmin(oAdmin);
            string[]       gArr  = oResult.GroupIDCSV.Split(',');
            entities.Group grp   = null;
            int            grpID = 0;
            Group          cGrop = null;

            oResult.Groups = new List <Group>();
            foreach (string s in gArr)
            {
                if (!string.IsNullOrEmpty(s) && Int32.TryParse(s, out grpID) && grpID > 0)
                {
                    grp = _GroupStorageAccess.GetGroupByID(grpID);

                    if (grp != null && grp.GroupID > 0)
                    {
                        cGrop = Caster.MakeContractGroupLite(grp);
                        if (cGrop != null && !string.IsNullOrEmpty(cGrop.GroupName) &&
                            !string.IsNullOrEmpty(cGrop.GroupID))
                        {
                            oResult.Groups.Add(cGrop);
                        }
                        else
                        {
                            utility.ResultsManager.AddResultInfo(oResult, ResultTypeEnum.Information,
                                                                 "The Group ID: " + s + " failed parsing");
                        }
                    }
                    else
                    {
                        utility.ResultsManager.AddResultInfo(oResult, ResultTypeEnum.Information,
                                                             "The Group ID: " + s + " is not available");
                    }
                }
            }

            return(oResult);
        }