public ActionResult Assign(string id) { UserIM uim = new UserIM(db); Util.Security.AES aes = new Util.Security.AES(); int tableId = Int16.Parse(aes.DecryptString(id)); table tab = im.find(tableId); user authUser = Util.User.UserUtil.getAuthenticatedUser(Request); if (authUser == null) { return RedirectToAction("LogOn", "User"); } user dbUser = uim.find(authUser.id); dbUser.current_table_id = tab.id; // TODO: This is a hack, the User crud is broken. dbUser.ConfirmPassword = dbUser.password; try { db.SaveChanges(); } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); } } } return RedirectToAction("UserMenu", "Menu"); }
public void AssignTest() { //Arrange Util.Security.AES aes = new Util.Security.AES(); string encryption = aes.EncryptToString(table1.id.ToString()); //Act RedirectToRouteResult actual = (RedirectToRouteResult)target.Assign(encryption); //Assert db = new touch_for_foodEntities(); Assert.AreEqual("Menu", actual.RouteValues["controller"]); Assert.AreEqual("UserMenu", actual.RouteValues["action"]); Assert.AreEqual(table1.id , db.users.Find(user1.id).current_table_id); }
public string generateNFCHash() { Util.Security.AES aes = new Util.Security.AES(); string toRet = aes.EncryptToString(this.id.ToString()); return toRet; }