public ActionResult Create(FormCollection collection) { try { // TODO: Add insert logic here LoginDetail lgd = new LoginDetail { LOGIN_USERNAME = collection["Username"], LOGIN_PASSWORD = collection["Password"], LOGIN_DISPLAY_NAME = collection["DisplayName"], LOGIN_EMAIL = collection["Email"], ROLE_ID = 2 }; String result = um.Insert(lgd); if (result == Constants.INSERT_SUCCESS) { return RedirectToAction("Login"); } else { ViewData["Error"] = result; return View(); } } catch { return View(); } }
public String Insert(LoginDetail lgd) { db.LoginDetails.InsertOnSubmit(lgd); try { db.SubmitChanges(); //inser success. Get id and make pass int id = lgd.LOGIN_ID; string newPass = id + lgd.LOGIN_PASSWORD; var update = from lg in db.LoginDetails where lg.LOGIN_ID == lgd.LOGIN_ID select lg; string result = Utils.GetHash(newPass, SampleWebsite.Libs.Utils.HashType.SHA1); update.Single().LOGIN_PASSWORD = result; db.SubmitChanges(); return Constants.INSERT_SUCCESS; } catch (Exception ex) { return ex.Message; } }
partial void DeleteLoginDetail(LoginDetail instance);
partial void UpdateLoginDetail(LoginDetail instance);
partial void InsertLoginDetail(LoginDetail instance);
private void detach_LoginDetails(LoginDetail entity) { this.SendPropertyChanging(); entity.RoleDetail = null; }