public ActionResult GiftItemNow(int itemid, int friendid) { prototype3.Models.ShoppingItem currentitem = _sdb.GetCurrentItem(itemid); prototype3.Models.User _source = userRep.GetUser((int)((User)Session["Current"]).UserID); prototype3.Models.User _dest = userRep.GetUser(friendid); if (currentitem.ItemPrice <= _source.Credits) { _source.Credits -= currentitem.ItemPrice; Transaction _trans = new Transaction() { AmountTransfered = currentitem.ItemPrice, CID = -1, Timestamp = DateTime.Now }; userRep.addTrans(_trans); userRep.Save(); } else { ViewData["msg"] = "You Dont Have Enough Credits."; } return(View("TransferCredits", _dest)); }
public ActionResult Edit(int id, FormCollection formValues) { prototype3.Models.User _user = userRep.GetUser(id); UpdateModel(_user); userRep.Save(); return(RedirectToAction("Details", new { id = _user.UserID })); }
public ActionResult FriendsPage(FormCollection formValues) { float _amttrans = float.Parse(Request.Form["_amount"]); //Get Source User (i.e. the current session master) prototype3.Models.User _source = userRep.GetUser((int)((User)Session["Current"]).UserID); //Get destination user prototype3.Models.User _dest = userRep.GetUser(int.Parse(Request.Form["_id"])); if (_amttrans <= _source.Credits) { //Perform the transaction of credit transfer _source.Credits -= float.Parse(Request.Form["_amount"]); _dest.Credits += float.Parse(Request.Form["_amount"]); userRep.Save(); //Submit the changes //reset the session with changed session master Session["Current"] = _source; //Record the transaction in to trans table Connection cn = userRep.GetFriendConnection(_source, _dest); Transaction _trans = new Transaction() { AmountTransfered = float.Parse(Request.Form["_amount"]), CID = cn.CID, Timestamp = DateTime.Now }; userRep.addTrans(_trans); userRep.Save(); } else { _source.Credits -= float.Parse(Request.Form["_amount"]); _dest.Credits += float.Parse(Request.Form["_amount"]); userRep.Save(); //Submit the changes //reset the session with changed session master Session["Current"] = _source; //Record the transaction in to trans table Connection cn = userRep.GetFriendConnection(_source, _dest); Transaction _trans = new Transaction() { AmountTransfered = float.Parse(Request.Form["_amount"]), CID = cn.CID, Timestamp = DateTime.Now }; ViewData["msg"] = "You Dont Have Enough Credits."; } return(View("TransferCredits", _dest)); }
public ActionResult AddAsFriend(int id) { //create an entry for connection of session master with profile user int id1 = (int)((prototype3.Models.User)Session["Current"]).UserID; //current session master id int id2 = id; //requested friend user id (passed in parameter) userRep.AddFriendRequest(id1, id2); userRep.Save(); //then return to the profile page now as friend prototype3.Models.User _user = userRep.GetUser(id); Response.Redirect("/User/FriendsPage/" + id); return(View("FriendsPage", _user)); }
public ActionResult Edit(int id) { prototype3.Models.User _user = userRep.GetUser(id); return(View(_user)); }