public ActionResult Add(AdvertisementViewModel model)
        {
            model.create_time = DateTime.Now;
            //AutoMapper自动映射
            Mapper.Initialize(cfg => cfg.CreateMap <AdvertisementViewModel, Advertisement>());
            Advertisement models = Mapper.Map <AdvertisementViewModel, Advertisement>(model);

            AdvertisementServices.Add(models);
            AdvertisementServices.SaverChanges();
            return(Json(new { status = "0" }, JsonRequestBehavior.AllowGet));
        }
Example #2
0
        public int Add()
        {
            var a = new Advertisement();

            a.ImgUrl = "123";
            a.Title  = "12312";
            a.Url    = "123";
            a.Remark = "123";

            return(_advertisementServices.Add(a));
        }
Example #3
0
        public async Task <MessageModel <string> > Post([FromBody] Advertisement request)
        {
            var data = new MessageModel <string>();

            var id = await _advertisementServices.Add(request);

            data.success = id > 0;

            if (data.success)
            {
                data.response = id.ObjToString();
                data.msg      = "添加成功";
            }

            return(data);
        }