Exemple #1
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);
        }
Exemple #2
0
        internal static contract.Admin MakeContractAdmin(entity.AdminUser admin)
        {
            if (admin == null)
            {
                return(null);
            }

            var oAdmin = new contract.Admin
            {
                AdminID              = admin.AdminID,
                Name                 = admin.Name,
                MobileNumber         = admin.MobileNumber,
                Email                = admin.Email,
                GroupIDCSV           = admin.GroupIDCSV,
                AllowGroupManagement = admin.AllowGroupManagement
            };

            return(oAdmin);
        }
Exemple #3
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);
        }