Exemple #1
0
        public ActionResult EditLocalePathway(long id, AddEditZonePathwayTemplateViewModel vModel)
        {
            string          message    = string.Empty;
            ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

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

            if (obj == null)
            {
                message = "That does not exist";
                return(RedirectToAction("Edit", new { Message = message, id }));
            }

            obj.Name             = vModel.DataObject.Name;
            obj.DegreesFromNorth = vModel.DataObject.DegreesFromNorth;
            obj.InclineGrade     = vModel.DataObject.InclineGrade;
            obj.Destination      = TemplateCache.Get <IRoomTemplate>(vModel.DestinationRoom.Id);

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

            return(RedirectToAction("Edit", new { Message = message, obj.Origin.Id }));
        }
Exemple #2
0
        public ActionResult AddEditLocalePath(long id, long localeId)
        {
            ILocaleTemplate locale = TemplateCache.Get <ILocaleTemplate>(localeId);

            if (locale == null)
            {
                return(RedirectToAction("Edit", new { Message = "Locale is invalid.", id }));
            }

            IEnumerable <IRoomTemplate> validRooms = TemplateCache.GetAll <IRoomTemplate>().Where(rm => rm.ParentLocation.Equals(locale));

            if (validRooms.Count() == 0)
            {
                return(RedirectToAction("Edit", new { Message = "Locale has no rooms.", id }));
            }

            IZoneTemplate origin = TemplateCache.Get <IZoneTemplate>(id);

            IPathwayTemplate existingPathway = origin.GetLocalePathways().FirstOrDefault(path => ((IRoomTemplate)path.Destination).ParentLocation.Equals(locale));

            AddEditZonePathwayTemplateViewModel vModel = new AddEditZonePathwayTemplateViewModel
            {
                AuthedUser = UserManager.FindById(User.Identity.GetUserId()),

                ValidMaterials = TemplateCache.GetAll <IMaterial>(),
                ValidModels    = TemplateCache.GetAll <IDimensionalModelData>().Where(model => model.ModelType == DimensionalModelType.Flat),
                ValidRooms     = validRooms,
            };

            if (existingPathway != null)
            {
                vModel.DataObject      = existingPathway;
                vModel.DestinationRoom = (IRoomTemplate)existingPathway.Destination;
            }
            else
            {
                vModel.DataObject = new PathwayTemplate()
                {
                    Origin = origin
                };
            }

            return(View("~/Views/GameAdmin/Zone/AddEditLocalePath.cshtml", vModel));
        }
Exemple #3
0
        public ActionResult AddLocalePathway(long id, AddEditZonePathwayTemplateViewModel vModel)
        {
            string          message    = string.Empty;
            ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

            IZoneTemplate    obj    = TemplateCache.Get <IZoneTemplate>(id);
            IPathwayTemplate newObj = vModel.DataObject;

            newObj.Destination = TemplateCache.Get <IRoomTemplate>(vModel.DestinationRoom.Id);
            newObj.Origin      = obj;

            if (newObj.Create(authedUser.GameAccount, authedUser.GetStaffRank(User)) == null)
            {
                message = "Error; Creation failed.";
            }
            else
            {
                LoggingUtility.LogAdminCommandUsage("*WEB* - AddPathway[" + newObj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
            }

            return(RedirectToAction("Edit", new { Message = message, id }));
        }