public ActionResult DeleteConfirmed(long id)
        {
            CompaniesPost companies = _companiesService.GetPost(id);

            companies.UserName = User.Identity.Name;
            _companiesService.Delete(companies);
            return(RedirectToAction("Index"));
        }
示例#2
0
        public JsonResult Delete(int id)
        {
            var result = new TaskResult();

            try
            {
                var company = _companiesService.GetById(id);

                if (company == null)
                {
                    result.AddErrorMessage("No puedes eliminar una Compañia que no existe.");
                }
                else if (company.UserId != _currentUser.UserId)
                {
                    result.AddErrorMessage("No puedes eliminar una Compañia que no creaste.");
                }

                result = _companiesService.Delete(company);
            }
            catch (Exception ex)
            {
                HttpContext.RiseError(ex);
                result.AddErrorMessage(ex.Message);
            }

            return(Json(result));
        }
        public async Task <IActionResult> Delete(int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(new ModelStateResult(ModelState)));
            }

            var deleteCompanyResultDto = await _companiesService.Delete(id, UserId);

            return(Ok(deleteCompanyResultDto));
        }
示例#4
0
        public IActionResult Delete(long id)
        {
            var company = _companiesService.Find(id);

            if (company == null)
            {
                return(NotFound());
            }

            _companiesService.Delete(id);
            return(new NoContentResult());
        }
示例#5
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            var result = _companiesService.Delete(id);

            return(RedirectToAction("Index", "UserPanel"));
        }
        public async Task <IActionResult> Delete(long id)
        {
            await _service.Delete(id);

            return(NoContent());
        }