public ActionResult saveMylisting() { try { string email = Session["email"].ToString(); AzureConnection db = new AzureConnection(); user_table v = db.user_table.Where(a => a.email == email).FirstOrDefault(); v.check_btc = Request.Form["check_btc"] == null ? false : true; v.btc_cash = Request.Form["btc_cash"] == null ? false : true; v.btc_cash_com = double.Parse(Request.Form["btc_cash_com"]); v.btc_wire = Request.Form["btc_wire"] == null ? false : true; v.btc_wire_com = double.Parse(Request.Form["btc_wire_com"]); v.check_eth = Request.Form["check_eth"] == null ? false : true; v.eth_cash = Request.Form["eth_cash"] == null ? false : true; v.eth_cash_com = double.Parse(Request.Form["eth_cash_com"]); v.eth_wire = Request.Form["eth_wire"] == null ? false : true; v.eth_wire_com = double.Parse(Request.Form["eth_wire_com"]); v.from_cash = double.Parse(Request.Form["from_cash"]); v.to_cash = double.Parse(Request.Form["to_cash"]); v.city = Request.Form["city"]; v.country = Request.Form["country"]; v.listme = Request.Form["listme"] == null ? false : true; db.SaveChanges(); return(RedirectToAction("mylistings")); } catch { return(RedirectToAction("", "Home")); } }
public string Post([FromBody] dynamic value) { chatEntities db = new chatEntities(); string username = value["username"]; if ((from u in db.user_table where u.username == username select u).Count() != 0) { return("用户名已存在"); } user_table usrModel = new user_table() { id = Guid.NewGuid().ToString(), username = value["username"], password = value["password"], privilege = 1, sex = value["sex"], age = value["age"], info = value["info"] }; db.user_table.Add(usrModel); int resCount = db.SaveChanges(); return(usrModel.id); }
/// <summary> /// 得到建议购买的食物名称 /// </summary> /// <param name="ds"></param> /// <returns></returns> public List <string> getTuiModel(List <dapei> ds) { user_table user = checkUser(); List <string> foodNames = new List <string>(); foreach (dapei d in ds) { string str = d.dp; str = str.Substring(1, str.Length - 2); string[] ar = str.Split(','); foreach (string s in ar) { if (foodNames.Contains(s)) { continue; } else { //目前食物不存在和吃完了 var query = from f in db.food where f.name == s && f.status == 0 select f; if (query.Count <food>() == 0) { foodNames.Add(s); } } } } return(foodNames); }
public ActionResult sendSmsCode() { try { string email = Session["email"].ToString(); AzureConnection db = new AzureConnection(); user_table v = db.user_table.Where(a => a.email == email).FirstOrDefault(); try { string code = Variables.sendSms(v.phone); Session["phoneCode"] = code; ViewData["step"] = "second"; ViewBag.Action = "google_auth"; return(View("google_auth")); } catch { ViewBag.Message = "Phone number isn't correct."; ViewData["step"] = "first"; ViewBag.Action = "google_auth"; return(View("google_auth")); } } catch { return(RedirectToAction("", "Home")); } }
public HttpResponseMessage registernewuser(user_table u) { dbe.user_table.Add(u); dbe.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.Accepted, "Signup Sucessfull")); }
/// <summary> /// 修改用户信息业务 /// </summary> /// <returns></returns> public ActionResult UpdateUserRequest(String nick, String heath, int gendre) { user_table user = checkUser(); user = db.user_table.SingleOrDefault <user_table>(u => u.id == user.id); if (nick.Length > 0) { user.nick = nick; } if (heath.Length > 0) { user.heath = heath; } if (user.sex != gendre) { user.sex = gendre; } int result = db.SaveChanges(); if (result > 0) { Session["user"] = user; Response.Redirect("/user/index"); } return(View()); }
public void SendVerificationLinkEmail(user_table tbdata) { var verifyUrl = "/User_Login/VerifyAccount/" + tbdata.emailCode; var link = Request.Url.AbsoluteUri.Replace(Request.Url.PathAndQuery, verifyUrl); var fromEmail = new MailAddress(WebConfigurationManager.AppSettings.Get("siteEmail"), "Lyohai"); var toEmail = new MailAddress(tbdata.email); var fromEmailPassword = WebConfigurationManager.AppSettings.Get("EmailPassword"); string subject = "Your account is successfully created"; string body = "<br/><br/>Dear " + tbdata.username + "<br/><br/>" + "Please click on the below link to verify your account" + "<br/><br/><a href='" + link + "'>" + link + "</a>";; var smtp = new SmtpClient { Host = "smtp-mail.outlook.com", Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new NetworkCredential(fromEmail.Address, fromEmailPassword) }; using (var message = new MailMessage(fromEmail, toEmail) { Subject = subject, Body = body, IsBodyHtml = true }) { smtp.Send(message); } }
/// <summary> /// 食物资料卡 /// </summary> /// <returns></returns> public ActionResult FoodIfoList(int?p) { if (p == null) { p = 1; } if (p < 1) { p = 1; } user_table user = checkUser(); var cards = from c in db.card join u in db.user_table on c.uid equals u.id join f in db.food on c.fid equals f.id where c.faid == user.fid orderby c.id descending select new CardModel { C = c, U = u, F = f }; int count = cards.Count <CardModel>(); List <CardModel> cardsModels = cards.Skip((p.Value - 1) * pagesize).Take(pagesize).ToList <CardModel>(); ViewData["cardsModels"] = cardsModels; ViewData["count"] = count; return(View()); }
/// <summary> /// 家庭主页 /// 1.家庭信息 /// 2.家庭成员信息 /// 3.留言列表 /// /// </summary> /// <returns></returns> public ActionResult FamilyPage() { user_table user = checkUser(); family fa = db.family.SingleOrDefault <family>(f => f.id == user.fid); ViewData["family"] = fa;//家庭信息 List <user_table> users = (from u in db.user_table where u.fid == fa.id && u.status == 0 select u).ToList <user_table>(); ViewData["users"] = users;//家庭成员信息 List <comment> comments = (from c in db.comment where c.fid == fa.id orderby c.id descending select c).ToList <comment>(); List <CommentModel> modes = new List <CommentModel>(); foreach (comment cs in comments) { CommentModel model = new CommentModel(); model.C = cs; user_table ut = db.user_table.SingleOrDefault <user_table>(u => u.id == cs.uid); model.U = ut; modes.Add(model); } ViewData["modes"] = modes;//留言信息 return(View()); }
public ActionResult user_info(string username) { AzureConnection db = new AzureConnection(); user_table user_data = db.user_table.Where(a => a.username == username).FirstOrDefault(); var trans_data = db.trans_history.Where(a => (a.seller == user_data.id || a.buyer == user_data.id)).ToArray(); ViewData["username"] = username; ViewData["star"] = 5; ViewData["rated_users"] = 30; ViewData["positive"] = 100; ViewData["no_trans"] = trans_data.Length; ViewData["btc"] = trans_data.Sum(x => x.btc) / trans_data.Length; if (ViewData["btc"].ToString() == "NaN") { ViewData["btc"] = 0; } ViewData["cash"] = trans_data.Sum(x => x.cash) / trans_data.Length; if (ViewData["cash"].ToString() == "NaN") { ViewData["cash"] = 0; } ViewData["country"] = (user_data.country == "gb" ? "UK": user_data.country).ToUpper(); ViewData["city"] = user_data.city; ViewData["avg"] = 2; return(View()); }
/// <summary> /// 拒绝加入家庭 /// </summary> /// <param name="id">用户id</param> /// <returns></returns> public ActionResult FamilyIdCancelRequest(int id) { user_table ut = db.user_table.SingleOrDefault <user_table>(u => u.id == id); ut.status = 3;//拒绝加入 db.SaveChanges(); return(Redirect("/home/messagePage")); }
/// <summary> /// 创建家庭成功页面,显示申请状态 /// </summary> /// <returns></returns> public ActionResult FamilyRequestStatus() { user_table u = checkUser(); u = db.user_table.SingleOrDefault <user_table>(us => us.id == u.id); Session["user"] = u; return(View()); }
/// <summary> /// 家庭成员列表 /// </summary> /// <returns></returns> public ActionResult FamilyMembers() { user_table user = checkUser(); List <user_table> users = (from u in db.user_table where u.fid == user.fid && u.status == 0 select u).ToList <user_table>(); ViewData["users"] = users;//家庭成员列表 return(View()); }
/// <summary> /// 家庭信息修改 /// </summary> /// <returns></returns> public ActionResult FamilyIfoUpdate() { user_table user = checkUser(); family f = db.family.SingleOrDefault <family>(fa => fa.id == user.fid); ViewData["family"] = f; return(View()); }
public ActionResult DeleteConfirmed(int id) { user_table user_table = db.user_tables.Find(id); db.user_tables.Remove(user_table); db.SaveChanges(); return(RedirectToAction("Index")); }
/// <summary> /// 用户编辑爱好 /// </summary> /// <returns></returns> public ActionResult UpdateUserCard() { user_table user = checkUser(); ucard uca = db.ucard.SingleOrDefault <ucard>(uc => uc.uid == user.id); ViewData["ucard"] = uca; return(View()); }
/// <summary> /// 重新申请 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult FamilyIdZaiRequest(int id) { user_table ut = db.user_table.SingleOrDefault <user_table>(u => u.id == id); ut.status = 2;//重新申请 db.SaveChanges(); Session["user"] = ut; return(Redirect("/user/FamilyRequestStatus")); }
/// <summary> /// 添加食物资料卡 /// </summary> /// <returns></returns> public ActionResult FoodIfoAdd() { user_table user = checkUser(); //需要食物信息 List <food> foods = (from f in db.food where f.fid == user.fid orderby f.id descending select f).ToList <food>(); ViewData["foods"] = foods; return(View()); }
/// <summary> /// 购买建议-根据食物搭配 /// </summary> /// <returns></returns> public ActionResult BuyAdviceByDaPei() { user_table user = checkUser(); List <dapei> ds = db.dapei.Where(da => da.fid == user.fid).Select(f => f).ToList <dapei>(); List <CardModel> cards = getModel(ds); ViewData["cards"] = cards; return(View()); }
public ActionResult Delete(int id) { user_table user = db.user_table.Find(id); db.user_table.Remove(user); db.SaveChanges(); return(RedirectToAction("Index")); }
//Get public ActionResult Edit(int?id) { user_table user = db.user_table.Find(id); if (user != null) { return(View(user)); } return(HttpNotFound()); }
/// <summary> /// 添加食物信息 /// </summary> /// <returns></returns> public ActionResult FoodAdd() { //获取分类 user_table user = checkUser(); List <cate> cates = (from c in db.cate where c.fid == user.fid select c).ToList <cate>(); ViewData["cates"] = cates; return(View()); }
public ActionResult Edit([Bind(Include = "u_id,user_name,user_address,user_password,user_type")] user_table user_table) { if (ModelState.IsValid) { db.Entry(user_table).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(user_table)); }
public ActionResult Delete(int?id) { if (id != null) { user_table user = db.user_table.Find(id); return(View(user)); } return(HttpNotFound()); }
/// <summary> /// 食物列表 /// </summary> /// <returns>食物信息、分类信息、用户信息</returns> public ActionResult FoodListPage(int?p) { if (p == null) { p = 1; } if (p < 1) { p = 1; } user_table user = checkUser(); var data = from f in db.food join c in db.cate on f.caid equals c.id join u in db.user_table on f.uid equals u.id where f.fid == user.fid && f.status == 0 orderby f.id descending select new FoodModel { U = u, C = c, F = f }; int count = data.Count <FoodModel>();//总数 List <FoodModel> foods = data.Skip((p.Value - 1) * pagesize).Take(pagesize).ToList <FoodModel>(); foreach (FoodModel fm in foods) { var eatCount = db.consume.Where(c => c.fid == fm.F.id).Select(c => c.kg).Sum(); if (eatCount != null) { if (eatCount.Value >= fm.F.kg.Value) { fm.EatCount = fm.F.kg.Value; food fo = db.food.SingleOrDefault <food>(f => f.id == fm.F.id); fo.status = 2; db.SaveChanges(); } else { fm.EatCount = eatCount.Value; } } else { fm.EatCount = 0.0; } } ViewData["foods"] = foods; ViewData["count"] = count; return(View()); }
/// <summary> /// 申请加入家庭请求 /// </summary> /// <param name="id">家庭id</param> /// <returns></returns> public ActionResult FamilyIdPageRequest(int id) { user_table ut = checkUser(); ut = db.user_table.SingleOrDefault <user_table>(u => u.id == ut.id); ut.fid = id; ut.status = 2;//已申请,等待审核 db.SaveChanges(); Session["user"] = ut; return(Redirect("/user/FamilyRequestStatus")); }
public string EditUser(user_table user) { string data; if (ModelState.IsValid) { db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return(data = "1"); } return(data = "0"); }
public ActionResult Create([Bind(Include = "u_id,user_name,user_address,user_password,user_type")] user_table user_table) { if (ModelState.IsValid) { user_table.user_password = this.Hash(user_table.user_password); db.user_tables.Add(user_table); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(user_table)); }
public HttpResponseMessage updatepassword(int password_hash, string email) { var response = 0; user_table user = dbe.user_table.Where(x => x.email_address == email).FirstOrDefault(); user.password_hash = password_hash; dbe.Entry(user).State = EntityState.Modified; response = dbe.SaveChanges(); string finalresponse = "password updated successfully - " + response; return(Request.CreateResponse(HttpStatusCode.OK, finalresponse)); }
public ActionResult Edit(int id) { user_table user = db.user_table.Find(id); if (TryUpdateModel(user, "", new string[] { "Email", "Username", "Password", "ConfirmPassword" })) { db.SaveChanges(); } return(RedirectToAction("Index")); }