Пример #1
0
 public ActionResult <string> Delete(string id)
 {
     try
     {
         return(Ok(_itemsService.Delete(id)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
 public ActionResult <String> Delete(int id)
 {
     try
     {
         var userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
         return(Ok(_its.Delete(id, userId)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Пример #3
0
        public void Delete_NoData_ReturnsNull()
        {
            var options = new DbContextOptionsBuilder <GameInfoContext>()
                          .UseInMemoryDatabase(databaseName: "NoItems_Db_ForDelete")
                          .Options;

            using (var context = new GameInfoContext(options))
            {
                var service = new ItemsService(context);
                Assert.False(service.Delete(2));
            }
        }
Пример #4
0
 public ActionResult <string> Delete(int id)
 {
     try
     {
         string userId = HttpContext.User.FindFirstValue("Id");
         return(Ok(_its.Delete(id, userId)));
     }
     catch (System.Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Пример #5
0
 public ActionResult <Item> Delete(int id)
 {
     try
     {
         string userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
         // NOTE DONT TRUST THE USER TO TELL YOU WHO THEY ARE!!!!
         return(Ok(_ls.Delete(id, userId)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Пример #6
0
 public ActionResult <SuccessResponse> Delete(int id)
 {
     try
     {
         ItemsService service = new ItemsService();
         service.Delete(id);
         SuccessResponse resp = new SuccessResponse();
         return(Ok(resp));
     }
     catch (Exception ex)
     {
         return(StatusCode(500, ex.Message.ToString()));
     }
 }
Пример #7
0
        public void Delete_WithData_DeletesItem()
        {
            var options = new DbContextOptionsBuilder <GameInfoContext>()
                          .UseInMemoryDatabase(databaseName: "Db_WithItems_ForDelete")
                          .Options;

            using (var context = new GameInfoContext(options))
            {
                context.Items.Add(new Item()
                {
                    Name = "ToDelete", AcquiredFrom = "None", Usage = "None"
                });
                context.SaveChanges();
            }

            using (var context = new GameInfoContext(options))
            {
                var service = new ItemsService(context);
                var result  = service.Delete(1);

                Assert.True(result);
                Assert.Equal(0, context.Items.Count());
            }
        }
Пример #8
0
        public async Task <IActionResult> DeleteForm(string keyValue)
        {
            await itemsApp.Delete(keyValue);

            return(Success("删除成功。"));
        }
Пример #9
0
        public void DeleteItemTest()
        {
            ItemsService itemsService = new ItemsService();

            itemsService.Delete(14682, _customerTestFixture.CustomerId, _customerTestFixture.AccessToken);
        }
Пример #10
0
 // GET: items/Delete/5
 public ActionResult Delete(int id)
 {
     cos.Delete(cos.GetById(id));
     return(RedirectToAction("Index"));
 }