public ActionResult Register(string phone, string name, string school, string code) { user user = entity.user.FirstOrDefault(p => p.phone == phone); if (user == null) { phonecode phonecode = entity.phonecode.FirstOrDefault(p => p.phone == phone); if (phonecode.code == code) { user new_user = new user() { name = name, phone = phone, school = school, sys_datetime = DateTime.Now, }; entity.user.Add(new_user); if (entity.SaveChanges() > 0) { HttpContext.Session["login"] = true; return(Json(true, JsonRequestBehavior.AllowGet)); } else { return(Json("系统发生错误,请稍后重试", JsonRequestBehavior.AllowGet)); } } return(Json("验证码无效", JsonRequestBehavior.AllowGet)); } return(Json("该手机号已被注册", JsonRequestBehavior.AllowGet)); }
public ActionResult Page_Add_Edit(int id, string title, string content) { if (id == 0) { page page = new page() { title = title, content = content, sys_datetime = DateTime.Now }; entity.page.Add(page); } else { var query = entity.page.FirstOrDefault(p => p.id == id); query.title = title; query.content = content; } return(Json(entity.SaveChanges() > 0, JsonRequestBehavior.AllowGet)); }
public ActionResult Register(string phone, string password, string code) { account_member member = entity.account_member.FirstOrDefault(p => p.phone == phone); if (member == null) { SMSTool tool = new SMSTool(); bool codeResult = tool.CheckCode(phone, code); if (codeResult == true) { account_member new_member = new account_member() { enable = true, password = DESTool.Encrypt(password), phone = phone, sys_datetime = DateTime.Now, }; entity.account_member.Add(new_member); if (entity.SaveChanges() > 0) { HttpContext.Session["tpmember"] = new_member; MessageTool.SendMessage(new_member.id, "系统通知", "恭喜您注册成功!"); return(Json(true, JsonRequestBehavior.AllowGet)); } return(Json("用户创建失败", JsonRequestBehavior.AllowGet)); } return(Json("验证码无效")); } return(Json("账号已被注册", JsonRequestBehavior.AllowGet)); }
private pay_order CreateOrder(int productId, string payMethod) { int id = MemberManager.GetMember().id; module_product product = entity.module_product.FirstOrDefault(p => p.id == productId); pay_order order = new pay_order() { member_id = id, product_id = productId, pay_time = null, price = product.price, delete = false, number = id.ToString().PadRight(15, '0') + DateTime.Now.ToString("yyyyMMddHHmmssfff"), pay_method = payMethod, remark = null, state_pay = false, sys_datetime = DateTime.Now, }; entity.pay_order.Add(order); entity.SaveChanges(); return(order); }
static void Main(string[] args) { using (var entityDB = new EntityDB()) { entityDB.Products.Add(new Product { Name = "Milk" }); entityDB.SaveChanges(); foreach (var product in entityDB.Products.ToList()) { Console.WriteLine(product.Name); } } }
public static bool SendMessage(int memberId, string title, string content) { EntityDB entity = new EntityDB(); member_message message = new member_message() { content = content, member_id = memberId, state_read = false, sys_datetime = DateTime.Now, title = title, }; entity.member_message.Add(message); return(entity.SaveChanges() > 0); }
static void Main(string[] args) { using (var entityDB = new EntityDB()) { entityDB.Products.Add(new Product { Name = "Milk" }); entityDB.SaveChanges(); foreach (var product in entityDB.Products.ToList()) { Console.WriteLine(product.Name); } } }
public ActionResult NewsDetail_Get(int id) { var query = entity.module_news.FirstOrDefault(p => p.id == id); query.views++; entity.SaveChanges(); return(Json(new { query.id, query.type_id, query.title, query.author, datetime = query.datetime.Value.ToString("yyyy-MM-dd"), query.path, query.description, query.top, query.views, query.content, }, JsonRequestBehavior.AllowGet)); }
public string CreateCode(string phone) { Random random = new Random(); string codeStr = random.Next(1000, 10000).ToString(); account_code account_code = entity.account_code.FirstOrDefault(p => p.phone == phone); if (account_code == null) { account_code new_account_code = new account_code() { code = codeStr, phone = phone, sys_datetime = DateTime.Now, }; entity.account_code.Add(new_account_code); } else { account_code.code = codeStr; account_code.sys_datetime = DateTime.Now; } entity.SaveChanges(); return(codeStr); }
public ActionResult Page_Add_Edit(lay_page pageModel) { if (pageModel.id == 0) { lay_page page = new lay_page() { title = pageModel.title, content = pageModel.content, sys_datetime = DateTime.Now }; entity.lay_page.Add(page); } else { var query = entity.lay_page.FirstOrDefault(p => p.id == pageModel.id); query.title = pageModel.title; query.content = pageModel.content; } return(Json(entity.SaveChanges() > 0, JsonRequestBehavior.AllowGet)); }
//--------------Insert------------------ public string Insert(User u) { db.Users.Add(u); db.SaveChanges(); return(u.Username); }