Ejemplo n.º 1
0
        public async Task <IActionResult> Save(AdvertisementDto model)
        {
            model.CategoryIds = model.CategoryIds?.Replace("null", "");
            if (model.Types.Contains(AdvertiseType.Banner.ToString("D")) && string.IsNullOrEmpty(model.ImageUrl))
            {
                return(ResultData(null, false, "宣传大图不能为空"));
            }

            if (model.Types.Length > 3 && string.IsNullOrEmpty(model.ThumbImgUrl))
            {
                return(ResultData(null, false, "宣传小图不能为空"));
            }

            var b = await AdsService.AddOrUpdateSavedAsync(a => a.Id, model.Mapper <Advertisement>()) > 0;

            return(ResultData(null, b, b ? "保存成功" : "保存失败"));
        }