Пример #1
0
 public IActionResult Delete(int id)
 {
     try
     {
         service.Delete(id);
         return(NoContent());
     }
     catch (Exception)
     {
         return(NotFound());
     }
 }
Пример #2
0
        public async Task <IActionResult> Delete(int id)
        {
            try
            {
                await service.Delete(id);

                return(NoContent());
            }
            catch (Exception ex)
            {
                return(NotFound(ex));
            }
        }
Пример #3
0
 public ApiResponseViewModel Delete(int id)
 {
     if (HttpContext.Current.Session["UserLogged"] == null)
     {
         return(CommonConstants.accessDenied);
     }
     return(_TypeService.Delete(id));
 }
Пример #4
0
        public ActionResult Delete(int id)
        {
            var response = _typeService.Delete(id);

            TempData["IsSuccess"] = response.IsSuccess;
            TempData["Message"]   = response.Message;
            return(RedirectToAction("Index"));
        }
Пример #5
0
        public IHttpActionResult Delete(int id)
        {
            Type item = service.Get(id);

            if (item != null)
            {
                service.Delete(item);
                return(Ok(item));
            }
            return(BadRequest());
        }
Пример #6
0
        public IActionResult Delete(int id)
        {
            if (!ModelState.IsValid)
            {
                return(new BadRequestObjectResult(ModelState));
            }

            _typeService.Delete(id);
            _typeService.Save();

            return(new OkObjectResult(id));
        }
 public ActionResult Delete(Type model)
 {
     try
     {
         service.Delete(model);
         return(RedirectToAction("Index", "Type"));
     }
     catch
     {
         return(View(model));
     }
 }
Пример #8
0
        public async Task <ActionResult <Type> > Delete(
            [FromRoute] string id,
            CancellationToken cancellationToken)
        {
            var tenantId    = "GET FROM JWT";
            var deletedType = await _typeService.Delete(
                id,
                tenantId,
                cancellationToken);

            return(Ok(deletedType));
        }
Пример #9
0
        public HttpResponseMessage Delete(HttpRequestMessage request, int id)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                if (!ModelState.IsValid)
                {
                    response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState);
                }
                else
                {
                    var oldType = _typeService.Delete(id);
                    _typeService.Save();

                    var responseData = Mapper.Map <Model.Models.Type, TypeViewModel>(oldType);
                    response = request.CreateResponse(HttpStatusCode.Created, responseData);
                }

                return response;
            }));
        }
 public IActionResult Delete(int id)
 {
     if (id == 0)
     {
         return(new BadRequestResult());
     }
     else
     {
         _typeService.Delete(id);
         _typeService.Save();
         return(new OkObjectResult(id));
     }
 }
Пример #11
0
        public void Delete()
        {
            //Arrange
            int ID = -1;

            unitWorkMock.Setup(x => x.Type.Delete(items[0].ID)).Callback(() =>
            {
                ID = items[0].ID;
            });

            //Act
            serviceMock.Delete(items[0]);

            //Assert
            Assert.AreNotEqual(-1, ID);
            Assert.AreEqual(id, ID);
        }
Пример #12
0
        public async Task <IActionResult> DeleteType(Guid id)
        {
            try
            {
                var user = await _userManager.GetUserAsync(User);

                if (user != null)
                {
                    var type = await _typeService.GetById(user, id);

                    if (type != null)
                    {
                        await _typeService.Delete(user, type);
                    }
                }
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }
            return(RedirectToAction(nameof(Index)));
        }
Пример #13
0
 public ActionResult DeleteConfirmed(int id)
 {
     Core.Type type = typeService.Get(id);
     typeService.Delete(type);
     return(RedirectToAction("Index"));
 }
Пример #14
0
        public void Delete(int id)
        {
            var result = _typeService.Delete(id);

            Assert.IsTrue(result.Success);
        }
Пример #15
0
 public IHttpActionResult Delete(int typeId)
 {
     _typeService.Delete(typeId);
     return(Ok());
 }