public async Task <ActionResult> Create(RSUser user, string newpassword, string confirmpassword) { if (ModelState.IsValid) { db.Users.Add(user); if (newpassword == confirmpassword) { user.DependencyInjection(); user.CreatePassword(newpassword); } else { ViewBag.ShowMessage = true; ViewBag.MessageColor = "red"; ViewBag.Message = Resources.Resources.PasswordsDontMatch; return(View(user)); } await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(user)); }
public async Task <ActionResult> Edit(RSUser user, string newpassword, string confirmpassword) { if (ModelState.IsValid) { db.Entry(user).State = EntityState.Modified; if (!string.IsNullOrWhiteSpace(newpassword) & newpassword == confirmpassword) { user.DependencyInjection(); user.CreatePassword(newpassword); } await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(user)); }
protected override void Seed(RSDbContext context) { try { if (!context.Users.Any()) { RSUser user0 = new RSUser() { Id = 0, Name = "Admin", Username = "******", IsAdmin = true, IsWaiter = true }; user0.DependencyInjection(); user0.CreatePassword("admin"); context.Users.AddOrUpdate(user0); } if (!context.Styles.Any(s => s.Type == (int)RSStyleType.MenuStyle)) { context.Styles.Add(new Models.RSStyle() { Path = "/Content/Menu/default.css", Selected = true, Title = "Default Menu Style", Type = (int)RSStyleType.MenuStyle, Notes = "This theme was provided by with the product to showcase menu printing capabilities of the product.", }); context.Styles.Add(new Models.RSStyle() { Path = "/Content/Receipt/default.css", Selected = true, Title = "Default Receipt Style", Type = (int)RSStyleType.MenuStyle, Notes = "This theme was provided by with the product to showcase receipt printing capabilities of the product.", }); } } catch (Exception ex) { } }
public bool LogIn(string username, string password) { using (RSDbContext Db = new RSDbContext()) { RSUser user = Db.Users.FirstOrDefault(u => u.Username == username); user.DependencyInjection(); if (user == null) { return(false); } if (!user.CheckPassword(password)) { return(false); } HttpContext.Current.Response.Cookies[COOKIE_NAME][COOKIE_USERNAME] = user.Username; HttpContext.Current.Response.Cookies[COOKIE_NAME][COOKIE_PASSWORDHASH] = BitConverter.ToString(user.PasswordHash); HttpContext.Current.Response.Cookies[COOKIE_NAME].Expires = DateTime.Now.AddDays(30); CurrentUser = user; return(true); } }