コード例 #1
0
        public ActionResult RemoveDescriptive(long id, string authorize)
        {
            string message = string.Empty;

            if (string.IsNullOrWhiteSpace(authorize))
            {
                message = "You must check the proper authorize radio button first.";
            }
            else
            {
                ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());
                string[]        values     = authorize.Split(new string[] { "|||" }, StringSplitOptions.RemoveEmptyEntries);

                if (values.Count() != 2)
                {
                    message = "You must check the proper authorize radio button first.";
                }
                else
                {
                    short  type   = short.Parse(values[0]);
                    string phrase = values[1];

                    IRoomTemplate obj = TemplateCache.Get <IRoomTemplate>(id);

                    if (obj == null)
                    {
                        message = "That does not exist";
                    }
                    else
                    {
                        GrammaticalType grammaticalType    = (GrammaticalType)type;
                        ISensoryEvent   existingOccurrence = obj.Descriptives.FirstOrDefault(occurrence => occurrence.Event.Role == grammaticalType &&
                                                                                             occurrence.Event.Phrase.Equals(phrase, StringComparison.InvariantCultureIgnoreCase));

                        if (existingOccurrence != null)
                        {
                            obj.Descriptives.Remove(existingOccurrence);

                            if (obj.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)))
                            {
                                LoggingUtility.LogAdminCommandUsage("*WEB* - RemoveDescriptive[" + id.ToString() + "|" + type.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
                                message = "Delete Successful.";
                            }
                            else
                            {
                                message = "Error; Removal failed.";
                            }
                        }
                        else
                        {
                            message = "That does not exist";
                        }
                    }
                }
            }

            return(RedirectToRoute("ModalErrorOrClose", new { Message = message }));
        }
コード例 #2
0
        public ActionResult AddEditDescriptive(long id, OccurrenceViewModel vModel)
        {
            string          message    = string.Empty;
            ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

            IRoomTemplate obj = TemplateCache.Get <IRoomTemplate>(id);

            if (obj == null)
            {
                message = "That does not exist";
                return(RedirectToRoute("ModalErrorOrClose", new { Message = message }));
            }

            ISensoryEvent existingOccurrence = obj.Descriptives.FirstOrDefault(occurrence => occurrence.Event.Role == vModel.SensoryEventDataObject.Event.Role &&
                                                                               occurrence.Event.Phrase.Equals(vModel.SensoryEventDataObject.Event.Phrase, StringComparison.InvariantCultureIgnoreCase));

            if (existingOccurrence == null)
            {
                existingOccurrence = new SensoryEvent(vModel.SensoryEventDataObject.SensoryType)
                {
                    Strength = vModel.SensoryEventDataObject.Strength,
                    Event    = new Lexica(vModel.SensoryEventDataObject.Event.Type,
                                          vModel.SensoryEventDataObject.Event.Role,
                                          vModel.SensoryEventDataObject.Event.Phrase, new LexicalContext(null))
                    {
                        Modifiers = vModel.SensoryEventDataObject.Event.Modifiers
                    }
                };
            }
            else
            {
                existingOccurrence.Strength    = vModel.SensoryEventDataObject.Strength;
                existingOccurrence.SensoryType = vModel.SensoryEventDataObject.SensoryType;
                existingOccurrence.Event       = new Lexica(vModel.SensoryEventDataObject.Event.Type,
                                                            vModel.SensoryEventDataObject.Event.Role,
                                                            vModel.SensoryEventDataObject.Event.Phrase, new LexicalContext(null))
                {
                    Modifiers = vModel.SensoryEventDataObject.Event.Modifiers
                };
            }

            obj.Descriptives.RemoveWhere(occurrence => occurrence.Event.Role == vModel.SensoryEventDataObject.Event.Role &&
                                         occurrence.Event.Phrase.Equals(vModel.SensoryEventDataObject.Event.Phrase, StringComparison.InvariantCultureIgnoreCase));

            obj.Descriptives.Add(existingOccurrence);

            if (obj.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)))
            {
                LoggingUtility.LogAdminCommandUsage("*WEB* - Room AddEditDescriptive[" + obj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
            }
            else
            {
                message = "Error; Edit failed.";
            }

            return(RedirectToRoute("ModalErrorOrClose", new { Message = message }));
        }
コード例 #3
0
        public ActionResult Edit(int id, AddEditRoomTemplateViewModel vModel)
        {
            ApplicationUser  authedUser        = UserManager.FindById(User.Identity.GetUserId());
            IPathwayTemplate zoneDestination   = null;
            IPathwayTemplate localeRoomPathway = null;

            IRoomTemplate obj = TemplateCache.Get <IRoomTemplate>(id);

            if (obj == null)
            {
                string message = "That does not exist";
                return(RedirectToRoute("ModalErrorOrClose", new { Message = message }));
            }

            obj.Name      = vModel.DataObject.Name;
            obj.Medium    = vModel.DataObject.Medium;
            obj.Qualities = vModel.DataObject.Qualities;

            if (vModel.ZonePathway?.Destination != null && !string.IsNullOrWhiteSpace(vModel.ZonePathway.Name))
            {
                IZoneTemplate destination = TemplateCache.Get <IZoneTemplate>(vModel.ZonePathway.Destination.Id);
                zoneDestination = obj.GetZonePathways().FirstOrDefault();

                if (zoneDestination == null)
                {
                    zoneDestination = new PathwayTemplate()
                    {
                        DegreesFromNorth = vModel.ZonePathway.DegreesFromNorth,
                        Name             = vModel.ZonePathway.Name,
                        Origin           = obj,
                        Destination      = destination,
                        InclineGrade     = vModel.ZonePathway.InclineGrade,
                        Model            = vModel.ZonePathway.Model
                    };
                }
                else
                {
                    zoneDestination.Model        = vModel.ZonePathway.Model;
                    zoneDestination.Name         = vModel.ZonePathway.Name;
                    zoneDestination.InclineGrade = vModel.ZonePathway.InclineGrade;

                    //We switched zones, this makes things more complicated
                    if (zoneDestination.Id != vModel.ZonePathway.Destination.Id)
                    {
                        zoneDestination.Destination = destination;
                    }
                }
            }

            if (vModel.LocaleRoomPathwayDestination != null && !string.IsNullOrWhiteSpace(vModel.LocaleRoomPathwayDestination.Name))
            {
                IRoomTemplate destination = TemplateCache.Get <IRoomTemplate>(vModel.LocaleRoomPathwayDestination.Id);
                localeRoomPathway = obj.GetLocalePathways().FirstOrDefault();

                if (localeRoomPathway == null)
                {
                    localeRoomPathway = new PathwayTemplate()
                    {
                        DegreesFromNorth = vModel.LocaleRoomPathway.DegreesFromNorth,
                        Name             = vModel.LocaleRoomPathway.Name,
                        Origin           = obj,
                        Destination      = destination,
                        InclineGrade     = vModel.LocaleRoomPathway.InclineGrade,
                        Model            = vModel.LocaleRoomPathway.Model
                    };
                }
                else
                {
                    localeRoomPathway.Model        = vModel.LocaleRoomPathway.Model;
                    localeRoomPathway.Name         = vModel.LocaleRoomPathway.Name;
                    localeRoomPathway.InclineGrade = vModel.LocaleRoomPathway.InclineGrade;
                    localeRoomPathway.Destination  = destination;
                }
            }

            if (obj.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)))
            {
                if (zoneDestination != null)
                {
                    zoneDestination.Save(authedUser.GameAccount, authedUser.GetStaffRank(User));
                }

                if (localeRoomPathway != null)
                {
                    localeRoomPathway.Save(authedUser.GameAccount, authedUser.GetStaffRank(User));
                }

                LoggingUtility.LogAdminCommandUsage("*WEB* - EditRoomTemplate[" + obj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
            }
            else
            {
            }

            return(RedirectToRoute("ModalErrorOrClose"));
        }