public async System.Threading.Tasks.Task <OperationResult <Company> > DeleteCompany(int id)
 {
     return(await System.Threading.Tasks.Task.Factory.StartNew <OperationResult <Company> >(() =>
     {
         OperationResult <Company> result = new OperationResult <Company>();
         try
         {
             if (IsInCompany(id))
             {
                 Company company = CompaniesRepository.Read(id);
                 if (company != null)
                 {
                     if (company.OwnerId == CurrentUser.Id)
                     {
                         result.Result = CompaniesRepository.Delete(id);
                         if (result.Result)
                         {
                             UserStore.RemoveFromRoleAsync(CurrentUser, RoleNames.CompanyOwner);
                         }
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             LoggingService.Log(ex);
         }
         return result;
     }));
 }
        public ActionResult DeleteAccount([FromODataUri] int key)
        {
            if (!ModelState.IsValid)
            {
                BadRequest(ModelState);
            }

            var result = _repository.RealAll().SingleOrDefault(x => x.Id == key);

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

            _repository.Delete(key);
            return(Ok(result));
        }