public HttpResponseMessage GetCurrencyById([FromBody] Models.currency currency) { var currencyId = currency.currency_id; var data = currencyRepository.GetCurrencyById(currencyId); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, data); return(response); }
public async Task<List<SwiftCurrency.Web.Models.currency>> GetCurrencyList() { var latestData = await this.InvokeHttpRoute(this.GetBaseurl() + "currencies.json?app_id=" + this.GetApiKey()); if (latestData != null || latestData != "") { var parsedData = JsonConvert.DeserializeObject<Dictionary<string, string>>(latestData); if (parsedData != null) { foreach (KeyValuePair<string, string> list in parsedData) { var tempListObject = new Models.currency(); tempListObject.currency_code = list.Key; tempListObject.currency_name = list.Value; this._currencyList.Add(tempListObject); } } } return this._currencyList; }
public HttpResponseMessage Post([FromBody] Models.currency currency) { try { if (string.IsNullOrEmpty(currency.currency_name)) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = "Currency is Empty" }, formatter)); } else { if (currencyRepository.CheckDuplicateCurrency(currency.currency_name)) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = "Currency Already Exists" }, formatter)); } else { currency insert_currency = new currency { currency_name = currency.currency_name }; currencyRepository.AddCurrency(insert_currency); var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "success", msg = "Currency save successfully" }, formatter)); } } } catch (Exception ex) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = ex.ToString() }, formatter)); } }
public HttpResponseMessage Delete([FromBody] Models.currency currency) { try { //long con_id = long.Parse(country_id); bool deleteCurrency = currencyRepository.DeleteCurrency(currency.currency_id); var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "success", msg = "Currency Delete Successfully." }, formatter)); } catch (Exception ex) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = ex.ToString() }, formatter)); } }
public HttpResponseMessage Put([FromBody] Models.currency currency) { try { Models.currency updateCurrency = new Models.currency { currency_id = currency.currency_id, currency_name = currency.currency_name }; currencyRepository.EditCurrency(updateCurrency); var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "success", msg = "Currency update successfully" }, formatter)); } catch (Exception ex) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = ex.ToString() }, formatter)); } }