Ejemplo n.º 1
0
        public string UpdateMap(string MapName, Map NewMapData, ChatroomEntity User)
        {
            MapValidityCheck       MapCheck    = CheckIfValid(NewMapData);
            UpdateMapValidityCheck Updatecheck = GetMapPositionInList(MapName);
            string ReturnMessage;

            if (MapCheck.IsValid && Updatecheck.MapExistsInList)
            {
                int entry = Updatecheck.MapEntry;

                if (mapList[entry].Submitter.ToString().Equals(User.identifier.ToString()) | User.Rank == ChatroomEntity.AdminStatus.True)
                {
                    mapList[entry].Filename    = NewMapData.Filename ?? mapList[entry].Filename;
                    mapList[entry].DownloadURL = NewMapData.DownloadURL;
                    mapList[entry].Notes       = NewMapData.Notes ?? mapList[entry].Notes;
                    mapList[entry].Uploaded    = NewMapData.Uploaded;

                    ReturnMessage = "Successfully updated the map!";
                }
                else
                {
                    ReturnMessage = "You are either not an admin or this isn't your map!";
                }
            }
            else
            {
                ReturnMessage = MapCheck.ReturnMessage;
            }

            return(ReturnMessage);
        }
Ejemplo n.º 2
0
        private UpdateMapValidityCheck GetMapPositionInList(string mapName)
        {
            UpdateMapValidityCheck ReturnData = new UpdateMapValidityCheck();

            int index = 0;

            foreach (Map Entry in mapList)
            {
                if (Entry.Filename.Equals(mapName))
                {
                    ReturnData.MapExistsInList = true;
                    ReturnData.MapEntry        = index;
                }
                else
                {
                    index++;
                }
            }
            return(ReturnData);
        }