Ejemplo n.º 1
0
        public async Task<IActionResult> Save(AdvertisementDto model)
        {
            model.CategoryId = model.CategoryId?.Replace("null", "");
            var entity = AdsService.GetById(model.Id);
            if (entity != null)
            {
                Mapper.Map(model, entity);
                bool b1 = await AdsService.SaveChangesAsync() > 0;
                return ResultData(null, b1, b1 ? "修改成功" : "修改失败");
            }

            bool b = AdsService.AddEntitySaved(model.Mapper<Advertisement>()) != null;
            return ResultData(null, b, b ? "添加成功" : "添加失败");
        }