Ejemplo n.º 1
0
        public async Task <ApiResult> Add(string Names, int Sorting, string Remark)
        {
            // 以接口的形式返回数据
            var res = new ApiResult();

            if (string.IsNullOrWhiteSpace(Names))
            {
                res.msg = "请填写标题";
            }
            else
            {
                try
                {
                    AdvertType m = new AdvertType()
                    {
                        Names   = Names,
                        Sorting = Sorting,
                        Remark  = Remark
                    };
                    res.success = db.Add(m) > 0;
                }
                catch (Exception ex)
                {
                    res.statusCode = (int)ApiEnum.Error;
                    res.msg        = ApiEnum.Error.GetEnumText() + ex.Message;
                }
            }
            // {"success":true,"message":null,"statusCode":200,"data":null}
            return(await Task.Run(() => res));
        }
Ejemplo n.º 2
0
        public IActionResult Create(AdvertType advertType)
        {
            var advertTypeResult = _advertTypeService.Add(advertType);

            TempData["SuccessMessage"] = advertTypeResult.Message;
            return(RedirectToAction("Index", "Admin"));
        }