示例#1
0
        public async Task <IActionResult> UpdateAsync([FromBody] RegisterVat command)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    // updates contract
                    VAT vat = Mapper.Map <VAT>(command);
                    _dbContext.Vats.Update(vat);
                    await _dbContext.SaveChangesAsync();

                    // send event
                    //RateRegistered e = Mapper.Map<RateRegistered>(command);
                    //await _messagePublisher.PublishMessageAsync(e.MessageType, e, "");

                    // return result
                    return(CreatedAtRoute("GetByContractId", new { contractId = vat.VatId }, vat));
                }
                return(BadRequest());
            }
            catch (DbUpdateException ex)
            {
                ModelState.AddModelError("", "Unable to save changes. " +
                                         "Try again, and if the problem persists " +
                                         "see your system administrator." + " -" + ex.Message);
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
示例#2
0
 public async Task UpdateVat(RegisterVat command)
 {
     try
     {
         await _client.UpdateVat(command);
     }
     catch (System.Exception e)
     {
         throw e.InnerException;
     }
 }
 public async Task <IActionResult> Update([FromForm] ContractManagementNewViewModel inputModel)
 {
     if (ModelState.IsValid)
     {
         return(await _resiliencyHelper.ExecuteResilient(async() =>
         {
             RegisterVat cmd = Mapper.Map <RegisterVat>(inputModel.Vat);
             await _contractManagementAPI.UpdateVat(cmd);
             return RedirectToAction("Index");
         }, View("Offline", new ContractManagementOfflineViewModel())));
     }
     else
     {
         return(View("New", inputModel));
     }
 }