public async Task <IActionResult> Delete(int id)
        {
            if (!User.Identity.IsAuthenticated)
            {
                throw new AuthenticationException();
            }
            var result = await _enterpriseService.DeleteEnterprise(id);

            var response = new ApiResponse <bool>(result);

            return(Ok(response));
        }
Пример #2
0
 public ActionResult <bool> DeleteEnterprise(int id)
 {
     try
     {
         var res = service.DeleteEnterprise(id);
         return(Ok(res));
     }
     catch (Exception ex)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));;
     }
 }
Пример #3
0
        public ActionResult Delete(Guid id, EnterpriseModel enterprise)
        {
            if (id == enterprise.Id)
            {
                try
                {
                    service.DeleteEnterprise(enterprise);
                    return(RedirectToAction("Index"));
                }
                catch (UpdateException)
                {
                    enterprise = service.GetEnterprise(id);
                    ViewData.Add(new KeyValuePair <string, object>(ViewRes.Enterprise.Erro + ':', ViewRes.Enterprise.UpdateException));
                }
                catch (Exception e)
                {
                    enterprise = service.GetEnterprise(id);
                    ModelState.AddModelError("", e.Message);
                    ViewData.Add(new KeyValuePair <string, object>(ViewRes.Enterprise.Erro + ':', ViewRes.Enterprise.UpdateException));
                }
            }

            return(View("Delete", enterprise));
        }