Beispiel #1
0
 public ActionResult <CompanyVM> PostCompany(CompanyVM companyVM)
 {
     if (ModelState.IsValid)
     {
         try
         {
             var userId = _userManager.GetUserId(User);
             if (_companyRepo.GetUserCompanyId(userId).Item1.HasValue)
             {
                 return(BadRequest(new { message = "Company already exist" }));
             }
             var result = _companyRepo.AddCompany(companyVM, userId);
             return(Ok(result));
         }
         catch (Exception e)
         {
             return(StatusCode(500, new { message = e.Message }));
         }
     }
     return(BadRequest());
 }