/// <summary> /// 删除商品 /// </summary> internal bool DelGoods(string sessionKey, string GoodsId) { ITopClient client = new DefaultTopClient(StaticSystemConfig.soft.ApiURL, StaticSystemConfig.soft.AppKey, StaticSystemConfig.soft.AppSecret, "json"); ItemDeleteRequest req = new ItemDeleteRequest(); req.NumIid = long.Parse(GoodsId); ItemDeleteResponse response = client.Execute(req, sessionKey); return(response.IsError); }
public async Task <ActionResult <Item> > DeleteItem(ItemDeleteRequest request) { try { var item = await _context.Items.FindAsync(request.ItemId); var itemList = await _context.ItemLists.Where(il => il.AccessCode == request.ListAccessCode).FirstAsync(); if (!itemList.IsPublic && itemList.ListPassword != request.ListPassword) { return(BadRequest("Wrong list password")); } _context.Items.Remove(item); await _context.SaveChangesAsync(); return(item); } catch { return(BadRequest("Proper list access code needed")); } }