public ActionResult CreateComment(CreateCommentModel model) { try { if (ModelState.IsValid) { if (CurrenciesManager.CurrencyExists(model.Currency)) { return(Json(CurrenciesManager.CreateComment(model.Currency, model.Message, model.Vote, Username), JsonRequestBehavior.AllowGet)); } else { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } } else { return(new HttpStatusCodeResult(HttpStatusCode.Forbidden)); } } catch { return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError)); } }
private void SaveCurrency() { Currency curr = new Currency(); CurrenciesManager manager = new CurrenciesManager(); curr.CurrencyID = hfId.Value != String.Empty ? Convert.ToInt32(hfId.Value) : 0; curr.CurrencyName = txtCurrency.Text; curr.CurrencySymbol = txtCurrencySymbol.Text; curr.ExchangeRate = Convert.ToDecimal(txtExchangeRate.Text); curr.System_Who_Add = ClientSession.Current.loginId; curr.System_LastAction_IP = ClientSession.Current.IP; if (manager.SaveCurrencyInfo(curr)) { // reset controls ResetControls(); // refresh saved data list ShowCurrenciesList(); } else { lblError.Text = Resources.AdminResources_en.ErrorSave; } }
public ActionResult GetCurrencies() { try { return(Json(CurrenciesManager.GetCurrencies(), JsonRequestBehavior.AllowGet)); } catch { return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError)); } }
public ActionResult Currency(string id) // id = shortCode { IncludeMenu("currencies"); if (CurrenciesManager.CurrencyExists(id)) { return(View(CurrenciesManager.GetCurrencyBySymbol(id).Id)); } else { return(RedirectToAction("Index")); } }
public ActionResult CreateCurrency(string displayName, string shortCode) { try { Guid currencyId = CurrenciesManager.CreateCurrency(displayName, shortCode, Username); return(Json(currencyId)); } catch { return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError)); } }
private void ShowExpenseDetails(int id) { var curr = new CurrenciesManager().GetCurrencyDetails(id); if (curr != null) { hfId.Value = curr.CurrencyID.ToString(); txtCurrency.Text = curr.CurrencyName; txtCurrencySymbol.Text = curr.CurrencySymbol; txtExchangeRate.Text = curr.ExchangeRate.ToString(); } else { lblError.Text = Resources.AdminResources_en.DataNotFound; } }
public ActionResult GetCurrency(string id) // id = currency id { try { if (Guid.TryParse(id, out Guid currencyId) && CurrenciesManager.CurrencyExists(currencyId)) { return(Json(CurrenciesManager.GetCurrencyById(currencyId), JsonRequestBehavior.AllowGet)); } else { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } } catch { return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError)); } }
private static void UpdateRates() { string json = ""; string url = @"https://api.coinmarketcap.com/v1/ticker/?convert=EUR"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.AutomaticDecompression = DecompressionMethods.GZip; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) using (Stream stream = response.GetResponseStream()) using (StreamReader reader = new StreamReader(stream)) { json = reader.ReadToEnd(); } var rates = JsonConvert.DeserializeObject <List <CmcCoinRates> >(json); List <CurrencyValueRates> models = rates.Select(x => x.ToModel()).ToList(); CurrenciesManager.UpdateRates(models); }
public CurrenciesController(IMapper mapper, CurrenciesManager currenciesManager) { _mapper = mapper; _currenciesManager = currenciesManager; }
public CryptoCurrencies(IMapper mapper, CurrenciesManager currenciesManager) { _mapper = mapper; _currenciesManager = currenciesManager; }
public OperationController() { operationsManager = new OperationsManager(database); categoriesManager = new CategoriesManager(database); currenciesManager = new CurrenciesManager(database); }