public IActionResult RemoveCompany([FromBody] int id)
        {
            try
            {
                Company company = new Company();
                company = _companiesRepository.GetCompanyById_model(id);

                if (company != null && company.UserId != null)
                {
                    if (company.UserId == IdentityHelper.GetUserId(HttpContext))
                    {
                        _companiesRepository.DeleteCompany(company);
                        return(Ok());
                    }
                    else
                    {
                        return(Unauthorized());
                    }
                }
                else
                {
                    return(BadRequest());
                }
            }
            catch (Exception ex)
            {
                return(BadRequest());
            }
        }
        public async Task <IActionResult> DeleteCompany()
        {
            var id = Helper.GetId(Request.Headers["Authorization"]);

            var result = await _repo.DeleteCompany(id);

            if (result == true)
            {
                return(Ok("Company deleted succesfully."));
            }
            return(StatusCode(500));
        }
        public IActionResult DeleteCompany(int id)
        {
            Company company = _companiesRepository.GetCompanyById(id);

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

            _companiesRepository.DeleteCompany(company);

            if (!_companiesRepository.Save())
            {
                return(StatusCode(500, "A problem happened with handling you request."));
            }

            return(NoContent());
        }
Example #4
0
        public async Task <IActionResult> Delete(int id)
        {
            await _companiesRep.DeleteCompany(id);

            return(RedirectToAction("Index"));
        }
Example #5
0
 public void DeleteCompany(long id)
 {
     _companiesRepository.DeleteCompany(id);
 }