public ActionResult CancelRequest(int id) { var result = db.tblTradeRequests.SingleOrDefault(x => x.requestId == id); if (result != null) { if (result.requestType == "B") { int reqQty = result.remainingQty ?? 0; decimal reqPrice = result.requestPrice ?? 0; var wallet = db.tblWallets.SingleOrDefault(x => x.uid == result.uid); wallet.balance = wallet.balance + (reqQty * reqPrice); db.SaveChanges(); } else if (result.requestType == "S") { int reqQty = result.remainingQty ?? 0; var holdings = db.tblHoldings.FirstOrDefault(x => x.uid == result.uid && x.stockId == result.stockId); holdings.remQty = holdings.remQty + reqQty; } result.requestStatus = "C"; db.SaveChanges(); } return(Redirect(Request.UrlReferrer.PathAndQuery)); }
public IHttpActionResult PuttblUser(int id, tblUser tblUser) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tblUser.uid) { return(BadRequest()); } db.Entry(tblUser).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!tblUserExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult edit(tblUser u) { tblUser s = e.tblUsers.Single(x => x.uid == u.uid); s = u; e.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "uid,fname,lname,email,mobile,dob,address,role,status")] tblUser tblUser) { if (ModelState.IsValid) { db.tblUsers.Add(tblUser); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tblUser)); }
public ActionResult Create([Bind(Include = "id,uid,userName,password,dateAdded")] tblAuthenticate tblAuthenticate) { if (ModelState.IsValid) { db.tblAuthenticates.Add(tblAuthenticate); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.uid = new SelectList(db.tblUsers, "uid", "fname", tblAuthenticate.uid); return(View(tblAuthenticate)); }
public ActionResult Create([Bind(Include = "stockId,stockName,quantity,quantity_remaining,addedBy,status")] tblStock tblStock) { if (ModelState.IsValid) { db.tblStocks.Add(tblStock); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.addedBy = new SelectList(db.tblUsers, "uid", "fname", tblStock.addedBy); return(View(tblStock)); }
public ActionResult EditUser([Bind(Include = "uid,fname,lname,email,mobile,dob,address,role,status")] tblUser tblUsers) { if (Session["user"] == null || Session["userName"] == null) { return(Redirect("~/Login.aspx")); } var us = Session["user"] as tblUser; tblUser u = manager.StpDBEntities.tblUsers.Find(us.uid); ViewBag.fname = u.fname; ViewBag.lname = u.lname; if (ModelState.IsValid) { db.Entry(tblUsers).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("ViewUsers")); } return(View(tblUsers)); }
public void UpdateTblTradeRequests(int reqId, int qty, int remQty) { tblTradeRequest trequest = db.tblTradeRequests.SingleOrDefault(x => x.requestId == reqId); trequest.remainingQty = remQty; if (remQty == 0) { trequest.requestStatus = "D"; } else if (remQty != qty) { trequest.requestStatus = "P"; } else { trequest.requestStatus = "O"; } db.SaveChanges(); }
protected void Unnamed1_Click(object sender, EventArgs e) { tblUser user = db.tblUsers.SingleOrDefault(x => x.email == email.Text); int? userId = null; int s = 0; if (user == null) { Label1.Text = "Email Not Registered"; Label1.ForeColor = Color.Red; } else { Session["user"] = user; emailbtn.Visible = false; code.Visible = true; submit.Visible = true; userId = user.uid; Random r = new Random(); String randcode = r.Next(0, 999999).ToString("D6"); tblCode ucode = db.tblCodes.SingleOrDefault(x => x.uid == userId); if (ucode == null) { tblCode newcode = new tblCode(); newcode.uid = userId; newcode.code = randcode; db.tblCodes.Add(newcode); db.SaveChanges(); } else { ucode.code = randcode; db.SaveChanges(); } s = SendCode(randcode, email.Text, user.fname); if (s == 1) { Label1.Text = "Code Sent"; Label1.ForeColor = Color.Green; } } }
protected void submit_Click(object sender, EventArgs e) { if (pass1.Text == pass2.Text) { tblUser user = Session["user"] as tblUser; tblAuthenticate auth = db.tblAuthenticates.SingleOrDefault(x => x.uid == user.uid); auth.password = pass1.Text; db.SaveChanges(); Session["userName"] = auth.userName; if (user.role == "U") { Response.Redirect("User/Dashboard"); } else if (user.role == "A") { Response.Redirect("Admin/Index"); } else { Label1.Text = "Some error ocuured , please contact us at [email protected]"; Label1.ForeColor = Color.Red; } } }