public ActionResult Register(FormCollection form) { bool isLogin = false; string id = (Session["id"] != null) ? Session["id"].ToString() : "-1"; if (id != "-1") { isLogin = true; } else { isLogin = false; } if (isLogin) { return(RedirectToAction("Index", "Forex")); } else { ForexHistoryEntities db = new ForexHistoryEntities(); member add = new member(); add.name = form["name"].Trim(); add.surName = form["surName"].Trim(); add.eMailAddress = form["eMailAddress"].Trim(); add.setPassword(form["password"]); db.member.Add(add); db.SaveChanges(); return(RedirectToAction("Login")); } }
public int isValidLogin(string eMailAddress, string password, bool crypt = true) { ForexHistoryEntities db = new ForexHistoryEntities(); member model = new member(); model.eMailAddress = eMailAddress; if (crypt) { model.setPassword(password); } else { model.password = password; } member resultMember = db.member.Where(x => x.eMailAddress == model.eMailAddress && x.password == model.password).SingleOrDefault(); try { if (resultMember.id != 0) { return(resultMember.id); } else { return(-1); } } catch (Exception e) { return(-1); } }
public member getMember(int id) { ForexHistoryEntities db = new ForexHistoryEntities(); member model = new member(); model = db.member.Find(id); return(model); }
// // GET: /HistoryItem/ public ActionResult Index() { int _userid = (Session["id"] != null) ? Convert.ToInt32(Session["id"].ToString()) : -1; apiController a = new apiController(); ViewBag.cur1 = "USD/TRY: " + a.get("getlatest", "usd", "try"); ViewBag.cur2 = "EUR/TRY: " + a.get("getlatest", "eur", "try"); ViewBag.cur3 = "GBP/TRY: " + a.get("getlatest", "gbp", "try"); ForexHistoryEntities db = new ForexHistoryEntities(); List <history> historyList = db.history.Where(x => x.userId == _userid).ToList(); return(View(historyList)); }
public ActionResult Login(FormCollection form) { bool isLogin = false; string id2 = (Session["id"] != null) ? Session["id"].ToString() : "-1"; if (id2 != "-1") { isLogin = true; } else { isLogin = false; } if (isLogin) { return(RedirectToAction("Index", "Forex")); } else { int id = isValidLogin(form["eMailAddress"], form["password"]); ForexHistoryEntities db = new ForexHistoryEntities(); if (id != -1) { member getOne = new member(); getOne = db.member.Find(id); Session["id"] = getOne.id; Session["eMailAddress"] = getOne.eMailAddress; Session["password"] = getOne.password; return(RedirectToAction("Index", "Forex")); } else { Session["id"] = "-1"; Session["eMailAddress"] = "INVALID"; Session["password"] = "******"; ViewBag.error = "Invalid login!"; return(View()); } } }