예제 #1
0
 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));
     }
 }
예제 #2
0
    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;
        }
    }
예제 #3
0
 public ActionResult GetCurrencies()
 {
     try
     {
         return(Json(CurrenciesManager.GetCurrencies(), JsonRequestBehavior.AllowGet));
     }
     catch
     {
         return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
     }
 }
예제 #4
0
 public ActionResult Currency(string id) // id = shortCode
 {
     IncludeMenu("currencies");
     if (CurrenciesManager.CurrencyExists(id))
     {
         return(View(CurrenciesManager.GetCurrencyBySymbol(id).Id));
     }
     else
     {
         return(RedirectToAction("Index"));
     }
 }
예제 #5
0
 public ActionResult CreateCurrency(string displayName, string shortCode)
 {
     try
     {
         Guid currencyId = CurrenciesManager.CreateCurrency(displayName, shortCode, Username);
         return(Json(currencyId));
     }
     catch
     {
         return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
     }
 }
예제 #6
0
    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;
        }
    }
예제 #7
0
 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));
     }
 }
예제 #8
0
        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);
        }
예제 #9
0
 public CurrenciesController(IMapper mapper, CurrenciesManager currenciesManager)
 {
     _mapper            = mapper;
     _currenciesManager = currenciesManager;
 }
예제 #10
0
 public CryptoCurrencies(IMapper mapper, CurrenciesManager currenciesManager)
 {
     _mapper            = mapper;
     _currenciesManager = currenciesManager;
 }
예제 #11
0
 public OperationController()
 {
     operationsManager = new OperationsManager(database);
     categoriesManager = new CategoriesManager(database);
     currenciesManager = new CurrenciesManager(database);
 }