示例#1
0
        public ActionResult Add(BonusModel model)
        {
            if (string.IsNullOrEmpty(model.ImagePath))
            {
                model.ImagePath = "";
            }
            else
            {
                string mapPath = IOHelper.GetMapPath(model.ImagePath);
                string name    = (new FileInfo(mapPath)).Name;
                IOHelper.CopyFile(mapPath, IOHelper.GetMapPath("/Storage/Plat/Bonus"), false, name);
                model.ImagePath = string.Concat("/Storage/Plat/Bonus/", name);
            }
            string str = string.Concat("http://", base.Request.Url.Host.ToString(), "/m-weixin/bonus/index/");

            _bonusService.Add(model, str);
            return(RedirectToAction("Management"));
        }
示例#2
0
        public ActionResult Add(BonusModel model)
        {
            if (!string.IsNullOrEmpty(model.ImagePath))
            {
                if (!HimallIO.ExistDir("/Storage/Plat/Bonus"))
                {
                    HimallIO.CreateDir("/Storage/Plat/Bonus");
                }
                //转移图片
                if (model.ImagePath.Contains("/temp/"))
                {
                    string source = model.ImagePath.Substring(model.ImagePath.LastIndexOf("/temp"));
                    string dest   = @"/Storage/Plat/Bonus/";
                    model.ImagePath = Path.Combine(dest, Path.GetFileName(source));
                    Core.HimallIO.CopyFile(source, model.ImagePath, true);
                }
                else if (model.ImagePath.Contains("/Storage/"))
                {
                    model.ImagePath = model.ImagePath.Substring(model.ImagePath.LastIndexOf("/Storage"));
                }
            }
            else
            {
                model.ImagePath = "";
            }

            model.StartTime = DateTime.Now;
            if (Himall.Entities.BonusInfo.BonusType.Prize == model.Type)
            {
                model.EndTime = DateTime.Now.AddYears(20);
            }
            string url = CurrentUrlHelper.CurrentUrlNoPort() + "/m-weixin/bonus/index/";

            _iBonusService.Add(model, url);
            return(RedirectToAction("Management"));

            throw new HimallException("验证失败");
        }
 /// <summary>
 ///  添加红包
 /// </summary>
 public static void Add(BonusInfo model, string baseAddress)
 {
     _iBonusService.Add(model, baseAddress);
 }