public IActionResult Put([FromBody] PolicyOrder policyOrder)
 {
     try
     {
         if (ModelState.IsValid && _unitOfWork.PolicyOrder.Update(policyOrder))
         {
             return(Ok(new { Message = "Orden Póliza, se ha actualizado" }));
         }
         else
         {
             return(BadRequest());
         }
     }
     catch (Exception ex)
     {
         return(StatusCode(500, "Internal server error: " + ex.Message));
     }
 }
 public IActionResult Post([FromBody] PolicyOrder policyOrder)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest());
         }
         string idUser = User.Claims.Where(c => c.Type.Equals(ClaimTypes.PrimarySid)).FirstOrDefault().Value;
         policyOrder.IdUser = int.Parse(idUser);
         if (policyOrder.IdExternalUser > 0)
         {
             policyOrder.IdUser = 1;
         }
         policyOrder.CreationDate = DateTime.Now;
         return(Ok(_unitOfWork.PolicyOrder.Insert(policyOrder)));
     }
     catch (Exception ex)
     {
         return(StatusCode(500, "Internal server error: " + ex.Message));
     }
 }
 public IActionResult ClosePolicyOrder([FromBody] PolicyOrder policyOrder)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest());
     }
     using (var transaction = new TransactionScope())
     {
         try
         {
             Management management = _unitOfWork.Management.ManagementByPolicyOrder(policyOrder.Id, "T");
             management.State = "R";
             _unitOfWork.Management.Update(management);
             _unitOfWork.PolicyOrderDetail.UpdateState(policyOrder.Id, "I");
             transaction.Complete();
             return(Ok());
         }
         catch (Exception ex)
         {
             transaction.Dispose();
             return(StatusCode(500, "Internal server error: " + ex.Message));
         }
     }
 }