public ActionResult Delete(string id = null) { baseusers user = baseUsers.GetUser(id); if (user == null) { return(HttpNotFound()); } return(View(user)); }
public ActionResult Edit(baseusers user) { if (ModelState.IsValid) { baseUsers.UpdateUser(user); return(RedirectToAction("Index")); } SelectList roles = new SelectList(UserRoles.RolesList); ViewBag.Roles = roles; return(View(user)); }
//[Authorize(Roles = "admin")] public ActionResult Edit(string id) { baseusers user = baseUsers.GetUser(id); if (user == null) { return(HttpNotFound()); } SelectList roles = new SelectList(UserRoles.RolesList); ViewBag.Roles = roles; return(View(user)); }
public ActionResult Create(baseusers user) { if (ModelState.IsValid) { baseUsers.AddUser(user); baseUsers.SaveChanges(); return(RedirectToAction("Index")); } SelectList roles = new SelectList(UserRoles.RolesList); ViewBag.Roles = roles; return(View(user)); }
public void Can_BaseUserService() { // Arrange Mock <IRepository> mockRepository = new Mock <IRepository>(); mockRepository.Setup(mRepo => mRepo.BaseUsers).Returns(new baseusers[] { new baseusers { Login = "******", Password = "******", ID = "d1f7908b-6967-42c2-be5d-b4f157168ac9" }, new baseusers { Login = "******", Password = "******", ID = "da9e2795-4818-4606-883f-8cf7d0a9c2fb" }, new baseusers { Login = "******", Password = "******", ID = "713e77ca-d526-49b1-8e34-8b71bc96bcd4" } }.AsQueryable()); // Create service BaseUsersService target = new BaseUsersService(mockRepository.Object); // Act baseusers user = target.GetUser("da9e2795-4818-4606-883f-8cf7d0a9c2fb"); // target.RemoveUser("d1f7908b-6967-42c2-be5d-b4f157168ac9"); // target.AddUser(new baseusers(){Login = "******", Password = "******"}); // Assert // GetUser Assert.AreEqual(user.Login, "guest"); Assert.AreEqual(target.GetAllBaseUsers().Count, 3); // RemoveUser, GetAllBaseUsers //Assert.AreEqual(target.GetAllBaseUsers()[0].Login, "guest"); //Assert.AreEqual(target.GetAllBaseUsers()[2].Login, "NewUser"); }
/// <summary> /// Update the group /// </summary> /// <param name="user">The group GUID.</param> /// <returns></returns> public void UpdateUser(baseusers user) { _entities.Context.Entry(user).State = EntityState.Modified; SaveChanges(); }
/// <summary> /// Update the group /// </summary> /// <param name="user">The group GUID.</param> /// <returns></returns> public void AddUser(baseusers user) { _entities.Context.baseusers.Add(user); SaveChanges(); }