public FormAuthenticationService(IMathHubDbContext mathHubDbContext) { // temporary login with Thanh Hai User ctx = mathHubDbContext.GetDbContext(); if (WebSecurity.IsAuthenticated) { user = ctx.Users.FirstOrDefault(t => t.Username.Equals(WebSecurity.CurrentUserName)); } }
public ActionResult Create(User user) { if (ModelState.IsValid) { db.Users.Add(user); db.SaveChanges(); return RedirectToAction("Index"); } return View(user); }
public static void Preparation() { StructureMapOfflineConfg.Configure(); IUserCommandService userCommandService = ObjectFactory.GetInstance<UserCommandService>(); IProblemCommandService problemCommandService = ObjectFactory.GetInstance<ProblemCommandService>(); ITagCommandService tagCommandService = ObjectFactory.GetInstance<TagCommandService>(); // create a user u = new User(); u.Username = "******"; u.Score = 0; userCommandService.InsertUser(u, null, null); Assert.IsTrue(u.Id > 0); // create an avatar link Image img = new Image(); img.Description = "this is a sample url"; img.Url = "www.google.com"; // create a new problem p = new Problem(); p.Title = "This is a hard problem"; p.Content = "This problem is so hard"; p.DateCreated = DateTime.Now; p.DateModified = DateTime.Now; p.UserId = u.Id; problemCommandService.AddProblem(p); Assert.IsTrue(p.Id > 0); // create custom tag t = new Tag(); t.Name = "Combinatoric"; t.Description = "this is a hard tag"; t.CreatorId = u.Id; t.DateCreated = DateTime.Now; t.DateModified = DateTime.Now; tagCommandService.CreateNewTag(t); }
public bool UpdateUser(User user) { return userRepository.Update(user); }
public bool InsertUser(User user, Profile profile, Image image) { return userRepository.Insert(user); }
public bool DeleteUser(User user) { return userRepository.Delete(user); }
public ActionResult Edit(User user) { if (ModelState.IsValid) { db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(user); }
public void SignOut() { WebSecurity.Logout(); user = null; }
public void SignOut() { user = new User(); WebSecurity.Logout(); }