Beispiel #1
0
        public ActionResult AddWithRoom(AddPathwayWithRoomTemplateViewModel vModel)
        {
            ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

            IRoomTemplate origin  = TemplateCache.Get <IRoomTemplate>(vModel.Origin.Id);
            IRoomTemplate newRoom = vModel.Destination;

            newRoom.ParentLocation = origin.ParentLocation;

            string message = string.Empty;

            if (newRoom.Create(authedUser.GameAccount, authedUser.GetStaffRank(User)) != null)
            {
                IPathwayTemplate newObj = vModel.DataObject;
                newObj.Destination = newRoom;
                newObj.Origin      = origin;

                if (newObj.Create(authedUser.GameAccount, authedUser.GetStaffRank(User)) == null)
                {
                    message = "Error; Creation failed.";
                }
                else
                {
                    if (vModel.CreateReciprocalPath)
                    {
                        PathwayTemplate reversePath = new PathwayTemplate
                        {
                            Name             = newObj.Name,
                            DegreesFromNorth = Utilities.ReverseDirection(newObj.DegreesFromNorth),
                            Origin           = newObj.Destination,
                            Destination      = newObj.Origin,
                            Model            = newObj.Model,
                            InclineGrade     = newObj.InclineGrade * -1
                        };

                        if (reversePath.Create(authedUser.GameAccount, authedUser.GetStaffRank(User)) == null)
                        {
                            message = "Reverse Path creation FAILED. Origin path creation SUCCESS.";
                        }
                    }

                    LoggingUtility.LogAdminCommandUsage("*WEB* - AddPathwayWithRoom[" + newObj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
                }
            }
            else
            {
                message = "Error; Creation failed.";
            }
            return(RedirectToRoute("ModalErrorOrClose", new { Message = message }));
        }
Beispiel #2
0
        public ActionResult Add(long localeId, AddEditRoomTemplateViewModel vModel)
        {
            string          message    = string.Empty;
            ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());
            ILocaleTemplate locale     = TemplateCache.Get <ILocaleTemplate>(localeId);

            IRoomTemplate newObj = vModel.DataObject;

            newObj.ParentLocation = locale;
            newObj.Coordinates    = new Coordinate(0, 0, 0); //TODO: fix this

            IPathwayTemplate zoneDestination = null;

            if (vModel.ZonePathway?.Destination != null && !string.IsNullOrWhiteSpace(vModel.ZonePathway.Name))
            {
                IZoneTemplate destination = TemplateCache.Get <IZoneTemplate>(vModel.ZonePathway.Destination.Id);
                zoneDestination = new PathwayTemplate()
                {
                    DegreesFromNorth = -1,
                    Name             = vModel.ZonePathway.Name,
                    Origin           = newObj,
                    Destination      = destination,
                    InclineGrade     = vModel.ZonePathway.InclineGrade,
                    Model            = vModel.ZonePathway.Model
                };
            }

            IPathwayTemplate localeRoomPathway = null;

            if (vModel.LocaleRoomPathwayDestination != null && !string.IsNullOrWhiteSpace(vModel.LocaleRoomPathwayDestination.Name))
            {
                IRoomTemplate destination = TemplateCache.Get <IRoomTemplate>(vModel.LocaleRoomPathwayDestination.Id);
                localeRoomPathway = new PathwayTemplate()
                {
                    DegreesFromNorth = vModel.LocaleRoomPathway.DegreesFromNorth,
                    Name             = vModel.LocaleRoomPathway.Name,
                    Origin           = newObj,
                    Destination      = destination,
                    InclineGrade     = vModel.LocaleRoomPathway.InclineGrade,
                    Model            = vModel.LocaleRoomPathway.Model
                };
            }


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

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

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

            return(RedirectToRoute("ModalErrorOrClose", new { Message = message }));
        }