public async Task <IActionResult> Post([FromBody] EnterpriseDto enterpriseDto)
        {
            if (!User.Identity.IsAuthenticated)
            {
                throw new AuthenticationException();
            }
            var enterprise = _mapper.Map <Enterprise>(enterpriseDto);
            await _enterpriseService.InsertEnterprise(enterprise);

            enterpriseDto = _mapper.Map <EnterpriseDto>(enterprise);
            var response = new ApiResponse <EnterpriseDto>(enterpriseDto);

            return(Ok(response));
        }
Beispiel #2
0
 public ActionResult Create(EnterpriseModel enterprise)
 {
     if (ModelState.IsValid)
     {
         try
         {
             if (enterprise.IsValid)
             {
                 service.InsertEnterprise(enterprise);
             }
             else
             {
                 ModelState.AddModelError("", enterprise.Error);
                 return(View("Create", enterprise));
             }
         }
         catch (Exception e)
         {
             ModelState.AddModelError("", e.Message);
             return(View("Create", enterprise));
         }
     }
     return(RedirectToAction("Index"));
 }
Beispiel #3
0
        public async Task <IActionResult> Post(EnterpriseDTO Enterprise)
        {
            await _enterpriseService.InsertEnterprise(Enterprise);

            return(Ok());
        }