public IActionResult GetCurrencyRates(int id) { try { return(Ok(ResponceViewModel <IEnumerable <CurrencyRateViewModel> > .GenerateRepsonce(service.GetRatesByCurrency(id)))); } catch (Exception ex) { logger.LogError($"Exception thrown in get currency rate by id {id}: {ex}"); return(BadRequest(ResponceViewModel <string> .GenerateError($"Get currency rate by id {id} failed: {ex.Message}"))); } }
public async Task <IActionResult> GetAll() { try { return(Ok(ResponceViewModel <IEnumerable <ClientViewModel> > .GenerateRepsonce(await appService.GetAll()))); } catch (Exception ex) { logger.LogError($"Exception thrown in get all clients: {ex}"); return(BadRequest(ResponceViewModel <string> .GenerateError($"Get all clients failed. {ex.Message}"))); } }
public IActionResult Update(int id, [FromBody] AccountViewModel model) { try { service.UpdateAccount(model); return(Ok(ResponceViewModel <string> .GenerateRepsonce("Update succeed."))); } catch (Exception ex) { logger.LogError($"Exception thrown in Update account: {ex}"); return(BadRequest(ResponceViewModel <string> .GenerateError($"Error in update account:{ex.Message}"))); } }
public IActionResult Add([FromBody] AccountViewModel model) { try { var acc = service.AddAccount(model); return(CreatedAtAction(nameof(GetById), new { id = acc.Id }, ResponceViewModel <AccountViewModel> .GenerateRepsonce(acc))); } catch (Exception ex) { logger.LogError($"Exception thrown in add account: {ex}"); return(BadRequest(ResponceViewModel <string> .GenerateError($"Error in add account:{ex.Message}"))); } }
public IActionResult Delete(int id) { try { service.DeleteAccount(id); return(Ok(ResponceViewModel <string> .GenerateRepsonce("Delete succeed."))); } catch (Exception ex) { logger.LogError($"Exception thrown in delete account: {ex}"); return(BadRequest(ResponceViewModel <string> .GenerateError($"Error in delete account: {ex.Message}"))); } }