Esempio n. 1
0
        public ActionResult Add(long Template = -1)
        {
            AddEditRaceViewModel vModel = new AddEditRaceViewModel(Template)
            {
                AuthedUser = UserManager.FindById(User.Identity.GetUserId())
            };

            return(View("~/Views/GameAdmin/Race/Add.cshtml", vModel));
        }
Esempio n. 2
0
        public ActionResult Add()
        {
            var vModel = new AddEditRaceViewModel();
            vModel.authedUser = UserManager.FindById(User.Identity.GetUserId());
            vModel.ValidMaterials = BackingDataCache.GetAll<Material>();
            vModel.ValidObjects = BackingDataCache.GetAll<InanimateData>();
            vModel.ValidRooms = BackingDataCache.GetAll<RoomData>();

            return View("~/Views/GameAdmin/Race/Add.cshtml", vModel);
        }
Esempio n. 3
0
        public ActionResult Edit(int id, string ArchivePath = "")
        {
            IRace obj = TemplateCache.Get <IRace>(id);

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

            AddEditRaceViewModel vModel = new AddEditRaceViewModel(ArchivePath, obj)
            {
                AuthedUser = UserManager.FindById(User.Identity.GetUserId())
            };

            return(View("~/Views/GameAdmin/Race/Edit.cshtml", vModel));
        }
Esempio n. 4
0
        public ActionResult Edit(int id, AddEditRaceViewModel vModel)
        {
            ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

            IRace  obj = TemplateCache.Get <IRace>(id);
            string message;

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

            obj.Name                 = vModel.DataObject.Name;
            obj.VisionRange          = vModel.DataObject.VisionRange;
            obj.TemperatureTolerance = vModel.DataObject.TemperatureTolerance;
            obj.Breathes             = vModel.DataObject.Breathes;
            obj.DietaryNeeds         = vModel.DataObject.DietaryNeeds;
            obj.TeethType            = vModel.DataObject.TeethType;
            obj.HelpText             = vModel.DataObject.HelpText;
            obj.CollectiveNoun       = vModel.DataObject.CollectiveNoun;
            obj.Arms                 = vModel.DataObject.Arms;
            obj.Legs                 = vModel.DataObject.Legs;
            obj.Torso                = vModel.DataObject.Torso;
            obj.Head                 = vModel.DataObject.Head;
            obj.StartingLocation     = vModel.DataObject.StartingLocation;
            obj.EmergencyLocation    = vModel.DataObject.EmergencyLocation;
            obj.SanguinaryMaterial   = vModel.DataObject.SanguinaryMaterial;
            obj.BodyParts            = vModel.DataObject.BodyParts;
            obj.DeathNoticeBody      = vModel.DataObject.DeathNoticeBody;
            obj.DeathQualityChanges  = vModel.DataObject.DeathQualityChanges;

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

            return(RedirectToAction("Index", new { Message = message }));
        }
Esempio n. 5
0
        public ActionResult Add(AddEditRaceViewModel vModel)
        {
            ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

            IRace  newObj = vModel.DataObject;
            string message;

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

            return(RedirectToAction("Index", new { Message = message }));
        }
Esempio n. 6
0
        public ActionResult Add(AddEditRaceViewModel vModel)
        {
            string message = string.Empty;
            var authedUser = UserManager.FindById(User.Identity.GetUserId());

            var newObj = new Race();
            newObj.Name = vModel.NewName;

            if (vModel.NewArmsID > 0 && vModel.NewArmsAmount > 0)
            {
                var arm = BackingDataCache.Get<InanimateData>(vModel.NewArmsID);

                if (arm != null)
                    newObj.Arms = new Tuple<IInanimateData, short>(arm, vModel.NewArmsAmount);
            }

            if (vModel.NewLegsID > 0 && vModel.NewLegsAmount > 0)
            {
                var leg = BackingDataCache.Get<InanimateData>(vModel.NewLegsID);

                if (leg != null)
                    newObj.Legs = new Tuple<IInanimateData, short>(leg, vModel.NewLegsAmount);
            }

            if (vModel.NewTorsoId > 0)
            {
                var torso = BackingDataCache.Get<InanimateData>(vModel.NewTorsoId);

                if (torso != null)
                    newObj.Torso = torso;
            }

            if (vModel.NewHeadId > 0)
            {
                var head = BackingDataCache.Get<InanimateData>(vModel.NewHeadId);

                if (head != null)
                    newObj.Head = head;
            }

            if (vModel.NewStartingLocationId > 0)
            {
                var room = BackingDataCache.Get<RoomData>(vModel.NewStartingLocationId);

                if (room != null)
                    newObj.StartingLocation = room;
            }

            if (vModel.NewRecallLocationId > 0)
            {
                var room = BackingDataCache.Get<RoomData>(vModel.NewRecallLocationId);

                if (room != null)
                    newObj.EmergencyLocation = room;
            }

            if (vModel.NewBloodId > 0)
            {
                var blood = BackingDataCache.Get<Material>(vModel.NewBloodId);

                if (blood != null)
                    newObj.SanguinaryMaterial = blood;
            }

            newObj.VisionRange = new Tuple<short, short>(vModel.NewVisionRangeLow, vModel.NewVisionRangeHigh);
            newObj.TemperatureTolerance = new Tuple<short, short>(vModel.NewTemperatureToleranceLow, vModel.NewTemperatureToleranceHigh);

            newObj.Breathes = (RespiratoryType)vModel.NewBreathes;
            newObj.DietaryNeeds = (DietType)vModel.NewDietaryNeeds;
            newObj.TeethType = (DamageType)vModel.NewTeethType;
            newObj.HelpText = vModel.NewHelpBody;

            if (vModel.NewExtraPartsId != null)
            {
                int partIndex = 0;
                var bodyBits = new List<Tuple<IInanimateData, short, string>>();
                foreach (var id in vModel.NewExtraPartsId)
                {
                    if (id > 0)
                    {
                        if (vModel.NewExtraPartsAmount.Count() <= partIndex || vModel.NewExtraPartsName.Count() <= partIndex)
                            break;

                        var currentName = vModel.NewExtraPartsName[partIndex];
                        var currentAmount = vModel.NewExtraPartsAmount[partIndex];
                        var partObject = BackingDataCache.Get<InanimateData>(id);

                        if (partObject != null && currentAmount > 0 && !string.IsNullOrWhiteSpace(currentName))
                            bodyBits.Add(new Tuple<IInanimateData, short, string>(partObject, currentAmount, currentName));
                    }

                    partIndex++;
                }

                newObj.BodyParts = bodyBits;
            }

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

            return RedirectToAction("Index", new { Message = message });
        }
Esempio n. 7
0
        public ActionResult Edit(int id)
        {
            string message = string.Empty;
            var vModel = new AddEditRaceViewModel();
            vModel.authedUser = UserManager.FindById(User.Identity.GetUserId());
            vModel.ValidMaterials = BackingDataCache.GetAll<IMaterial>();
            vModel.ValidObjects = BackingDataCache.GetAll<IInanimateData>();
            vModel.ValidRooms = BackingDataCache.GetAll<IRoomData>();

            var obj = BackingDataCache.Get<IRace>(id);

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

            vModel.DataObject = obj;
            vModel.NewName = obj.Name;
            vModel.NewArmsAmount = obj.Arms.Item2;
            vModel.NewArmsID = obj.Arms.Item1.ID;
            vModel.NewBloodId = obj.SanguinaryMaterial.ID;
            vModel.NewBreathes = (short)obj.Breathes;
            vModel.NewDietaryNeeds = (short)obj.DietaryNeeds;
            vModel.NewHeadId = obj.Head.ID;
            vModel.NewLegsAmount = obj.Legs.Item2;
            vModel.NewLegsID = obj.Legs.Item1.ID;
            vModel.NewRecallLocationId = obj.EmergencyLocation.ID;
            vModel.NewStartingLocationId = obj.StartingLocation.ID;
            vModel.NewTeethType = (short)obj.TeethType;
            vModel.NewTemperatureToleranceHigh = obj.TemperatureTolerance.Item2;
            vModel.NewTemperatureToleranceLow = obj.TemperatureTolerance.Item1;
            vModel.NewTorsoId = obj.Torso.ID;
            vModel.NewVisionRangeHigh = obj.VisionRange.Item2;
            vModel.NewVisionRangeLow = obj.VisionRange.Item1;
            vModel.NewHelpBody = obj.HelpText;

            vModel.NewExtraPartsAmount = obj.BodyParts.Select(bp => bp.Item2).ToArray();
            vModel.NewExtraPartsId = obj.BodyParts.Select(bp => bp.Item1.ID).ToArray(); ;
            vModel.NewExtraPartsName = obj.BodyParts.Select(bp => bp.Item3).ToArray(); ;

            return View("~/Views/GameAdmin/Race/Edit.cshtml", vModel);
        }
Esempio n. 8
0
        public ActionResult AddRaceData()
        {
            var vModel = new AddEditRaceViewModel();
            vModel.authedUser = UserManager.FindById(User.Identity.GetUserId());
            vModel.ValidMaterials = ReferenceWrapper.GetAll<Material>();
            vModel.ValidObjects = DataWrapper.GetAll<InanimateData>();
            vModel.ValidRooms = DataWrapper.GetAll<RoomData>();

            return View(vModel);
        }