Esempio n. 1
0
        public ActionResult Add(AddEditFloraViewModel vModel)
        {
            string          message    = string.Empty;
            ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

            IFlora newObj = vModel.DataObject;

            if (newObj.Wood == null && newObj.Flower == null && newObj.Seed == null && newObj.Leaf == null && newObj.Fruit == null)
            {
                message = "At least one of the parts of this plant must be valid.";
            }

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

            return(RedirectToAction("Index", new { Message = message }));
        }
Esempio n. 2
0
        public ActionResult Remove(long removeId = -1, string authorizeRemove = "", long unapproveId = -1, string authorizeUnapprove = "")
        {
            string message;

            if (!string.IsNullOrWhiteSpace(authorizeRemove) && removeId.ToString().Equals(authorizeRemove))
            {
                ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

                IFlora obj = TemplateCache.Get <IFlora>(removeId);

                if (obj == null)
                {
                    message = "That does not exist";
                }
                else if (obj.Remove(authedUser.GameAccount, authedUser.GetStaffRank(User)))
                {
                    LoggingUtility.LogAdminCommandUsage("*WEB* - RemoveFlora[" + removeId.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
                    message = "Delete Successful.";
                }
                else
                {
                    message = "Error; Removal failed.";
                }
            }
            else if (!string.IsNullOrWhiteSpace(authorizeUnapprove) && unapproveId.ToString().Equals(authorizeUnapprove))
            {
                ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

                IFlora obj = TemplateCache.Get <IFlora>(unapproveId);

                if (obj == null)
                {
                    message = "That does not exist";
                }
                else if (obj.ChangeApprovalStatus(authedUser.GameAccount, authedUser.GetStaffRank(User), ApprovalState.Returned))
                {
                    LoggingUtility.LogAdminCommandUsage("*WEB* - UnapproveFlora[" + unapproveId.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
                    message = "Unapproval Successful.";
                }
                else
                {
                    message = "Error; Unapproval failed.";
                }
            }
            else
            {
                message = "You must check the proper remove or unapprove authorization radio button first.";
            }

            return(RedirectToAction("Index", new { Message = message }));
        }
Esempio n. 3
0
        public ActionResult Edit(long id, AddEditFloraViewModel vModel)
        {
            string          message    = string.Empty;
            ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

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

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

            obj.Name               = vModel.DataObject.Name;
            obj.HelpText           = vModel.DataObject.HelpText;
            obj.SunlightPreference = vModel.DataObject.SunlightPreference;
            obj.Coniferous         = vModel.DataObject.Coniferous;
            obj.AmountMultiplier   = vModel.DataObject.AmountMultiplier;
            obj.Rarity             = vModel.DataObject.Rarity;
            obj.PuissanceVariance  = vModel.DataObject.PuissanceVariance;
            obj.ElevationRange     = vModel.DataObject.ElevationRange;
            obj.TemperatureRange   = vModel.DataObject.TemperatureRange;
            obj.HumidityRange      = vModel.DataObject.HumidityRange;
            obj.Wood               = vModel.DataObject.Wood;
            obj.Flower             = vModel.DataObject.Flower;
            obj.Seed               = vModel.DataObject.Seed;
            obj.Leaf               = vModel.DataObject.Leaf;
            obj.Fruit              = vModel.DataObject.Fruit;
            obj.OccursIn           = vModel.DataObject.OccursIn;

            if (obj.Wood == null && obj.Flower == null && obj.Seed == null && obj.Leaf == null && obj.Fruit == null)
            {
                message = "At least one of the parts of this plant must be valid.";
            }

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

            return(RedirectToAction("Index", new { Message = message }));
        }
Esempio n. 4
0
        public ActionResult Edit(long id, string ArchivePath = "")
        {
            IFlora obj = TemplateCache.Get <IFlora>(id);

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

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

            return(View("~/Views/GameAdmin/Flora/Edit.cshtml", vModel));
        }