Ejemplo n.º 1
0
        public async Task <IActionResult> UpdateAsync([FromBody] RegisterRate command)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    // insert customer
                    Rate rate = Mapper.Map <Rate>(command);
                    _dbContext.Rates.Update(rate);
                    //_dbContext.Rates.Add(rate);
                    await _dbContext.SaveChangesAsync();

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

                    // return result
                    return(CreatedAtRoute("GetByRateId", new { rateId = rate.RateId }, rate));
                }
                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));
            }
        }
Ejemplo n.º 2
0
 public async Task RegisterRate(RegisterRate command)
 {
     try
     {
         await _client.RegisterRate(command);
     }
     catch (System.Exception e)
     {
         throw e.InnerException;
     }
 }
Ejemplo n.º 3
0
 public async Task <IActionResult> Update([FromForm] ContractManagementNewViewModel inputModel)
 {
     if (ModelState.IsValid)
     {
         return(await _resiliencyHelper.ExecuteResilient(async() =>
         {
             RegisterRate cmd = Mapper.Map <RegisterRate>(inputModel.Rate);
             await _contractManagementAPI.UpdateRate(cmd);
             return RedirectToAction("Index");
         }, View("Offline", new ContractManagementOfflineViewModel())));
     }
     else
     {
         return(View("New", inputModel));
     }
 }