Exemple #1
0
        public ActionResult EditActivityConfig(AwardModel award)
        {
            int count            = 0;
            var IsNewAward       = true;
            var newLine          = award.AwardId + "," + award.RatioBegain + "," + award.RatioEnd + "," + award.AwardMessage + "," + (award.IsAward ? "true" : "false");
            var textPath         = Server.MapPath("~") + "Areas\\Activity\\ActivityConfiguration.txt";
            var configContent    = TextProcessHelper.GetTextLines(textPath);
            var newConfigContent = new List <string>();

            foreach (var content in configContent)
            {
                count++;
                if (content.StartsWith(award.AwardId))
                {
                    newConfigContent.Add(newLine);
                    IsNewAward = false;
                }
                else
                {
                    newConfigContent.Add(content);
                    if (count == configContent.Count && IsNewAward)
                    {
                        newConfigContent.Add(newLine);
                    }
                }
            }
            if (!configContent.Any())
            {
                newConfigContent.Add(newLine);
            }
            TextProcessHelper.WriteText(textPath, newConfigContent);
            return(RedirectToAction("ActivityGetAwardConfigGet"));
        }
Exemple #2
0
        public ActionResult DeleteAwardbyId(string id)
        {
            var textPath         = Server.MapPath("~") + "Areas\\Activity\\ActivityConfiguration.txt";
            var configContent    = TextProcessHelper.GetTextLines(textPath);
            var newConfigContent = new List <string>();

            configContent = configContent.Where(o => !o.StartsWith(id)).ToList();
            TextProcessHelper.WriteText(textPath, configContent);
            return(RedirectToAction("ActivityGetAwardConfigGet"));
            //return Content("删除成功!");
        }