示例#1
0
        //public async Task<ActionResult> EmailFalse(string userId, bool value)
        //{


        //    return  RedirectToAction("ChangeEmailStatus", new { userid = userId, value = value });
        //}

        //public PartialViewResult Details()
        //{
        //    //sample s = new sample();
        //    sample s = new sample();
        //    s.no = 1;
        //    ViewBag.a="Naresh......";
        //    return PartialView("At");
        //}
        //public ActionResult Demo()
        //{
        //    sample s = new sample();
        //    s.no = 1;
        //    Details();
        //    return View(s);
        //}
        public ActionResult PostSession(SecurityViewModel obj, string [] DynamicTextBox)
        {
            if (DynamicTextBox != null)
            {
                string id = User.Identity.GetUserId(); string Mac = "Null"; string location = "Null";
                foreach (var r in DynamicTextBox)
                {
                    string Ip = r;
                    if (Ip != "")
                    {
                        ValueController.PostSecurityData(id, Ip, Mac, location, true);
                    }
                }
                TempData["success"] = "IP Adress successfully updated....!";
                return(RedirectToAction("Security"));
            }
            if (!ModelState.IsValid)
            {
                try { ViewBag.BTC = "$" + Math.Round(Convert.ToDecimal(objCoin.BTCCurrentPrice()), 2); } catch (Exception ex) { ViewBag.BTC = ex.Message; }
                try { ViewBag.ETH = "$" + Math.Round(Convert.ToDecimal(objCoin.ETHCurrentPrice()), 2); } catch (Exception ex) { ViewBag.ETH = ex.Message; }
                try { ViewBag.DASH = "$" + Math.Round(Convert.ToDecimal(objCoin.DASHCurrentPrice()), 2); } catch (Exception ex) { ViewBag.DASH = ex.Message; }
                try { ViewBag.LTC = "$" + Math.Round(Convert.ToDecimal(objCoin.LTCCurrentPrice()), 2); } catch (Exception ex) { ViewBag.LTC = ex.Message; }
                try { ViewBag.ETC = "$" + Math.Round(Convert.ToDecimal(objCoin.ETCCurrentPrice()), 2); } catch (Exception ex) { ViewBag.ETC = ex.Message; }
                try { ViewBag.MBC = "$" + Math.Round(Convert.ToDecimal(objCoin.GetMBC_USDCoin()), 2); } catch (Exception ex) { ViewBag.MBC = ex.Message; }
                obj.s = Session["EmailStatus"] as sample;
                return(View("Settings", obj));
            }

            var userId = User.Identity.GetUserId();

            obj.Sm.UserId = userId;
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(url + "Transaction/PostSession");
                var postTask = client.PostAsJsonAsync(url + "Transaction/PostSession", obj);
                postTask.Wait();
                var result = postTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    ModelState.Clear();
                    TempData["success"] = "Security Session succeccfully updated...";
                    return(RedirectToAction("Security"));
                }
            }

            ModelState.AddModelError(string.Empty, "Server Error. Please contact administrator.");

            obj.s = Session["EmailStatus"] as sample;

            try { ViewBag.BTC = "$" + Math.Round(Convert.ToDecimal(objCoin.BTCCurrentPrice()), 2); } catch (Exception ex) { ViewBag.BTC = ex.Message; }
            try { ViewBag.ETH = "$" + Math.Round(Convert.ToDecimal(objCoin.ETHCurrentPrice()), 2); } catch (Exception ex) { ViewBag.ETH = ex.Message; }
            try { ViewBag.DASH = "$" + Math.Round(Convert.ToDecimal(objCoin.DASHCurrentPrice()), 2); } catch (Exception ex) { ViewBag.DASH = ex.Message; }
            try { ViewBag.LTC = "$" + Math.Round(Convert.ToDecimal(objCoin.LTCCurrentPrice()), 2); } catch (Exception ex) { ViewBag.LTC = ex.Message; }
            try { ViewBag.ETC = "$" + Math.Round(Convert.ToDecimal(objCoin.ETCCurrentPrice()), 2); } catch (Exception ex) { ViewBag.ETC = ex.Message; }
            try { ViewBag.MBC = "$" + Math.Round(Convert.ToDecimal(objCoin.GetMBC_USDCoin()), 2); } catch (Exception ex) { ViewBag.MBC = ex.Message; }

            return(View("Security", obj));
        }