Пример #1
0
        ///// <summary>
        ///// 批量删除
        ///// </summary>
        ///// <param name="context"></param>
        //public void DeleteListFavoriteRequest(HttpContext context)
        //{
        //    // ?
        //}


        ///// <summary>
        ///// 搜索
        ///// </summary>
        ///// <param name="context"></param>
        //public void SeachFavoriteRequest(HttpContext context)
        //{
        //    //var title = context.Request["name"];
        //    //var page = context.Request.Form["page"];
        //    //var index = context.Request.Form["limit"];
        //    //if (string.IsNullOrWhiteSpace(page) && string.IsNullOrWhiteSpace(index))
        //    //{
        //    //    var list = _InfoService.GetList().Where(y => y.Title.Contains(title)).ToList();
        //    //    var res = SerializeHelp.ToTableJson(list);
        //    //    context.Response.Write(res);
        //    //}
        //    //else
        //    //{
        //    //    var list = _InfoService.GetList().Where(y => y.Title.Contains(title)).ToList();
        //    //    var list1 = list.Skip((int.Parse(page) - 1) * int.Parse(index)).Take(int.Parse(index)).ToList();
        //    //    var res = SerializeHelp.ToTableJson(list1, list.Count());
        //    //    context.Response.Write(res);
        //    //}
        //}

        /// <summary>
        ///删除
        /// </summary>
        /// <param name="context"></param>
        public void DeleteFavoriteRequest(HttpContext context)
        {
            var response = new ResponseMessage();

            try
            {
                var id  = context.Request["id"];
                var del = _InfoService.Delete(id);
                if (del)
                {
                    response.code = 0;
                    response.msg  = "删除成功";
                    context.Response.Write(SerializeHelp.ToJson(response));
                }
                response.code = 500;
                response.msg  = "删除失败";
                context.Response.Write(SerializeHelp.ToJson(response));
            }
            catch (Exception e)
            {
                response.code = 500;
                response.msg  = "删除失败";
                context.Response.Write(SerializeHelp.ToJson(response));
            }
        }
Пример #2
0
        public IActionResult Delete(string id)
        {
            var Favorite = _favoriteService.Get(id);

            if (Favorite == null)
            {
                return(NotFound());
            }
            _favoriteService.Delete(Favorite.Id);
            return(NoContent());
        }