public ActionResult CheckMobileExist(string lsMobile) { EducationDataContext loEduContext = new EducationDataContext(); Boolean lbIsExistMobile = loEduContext.GetMobile(lsMobile); return(Json(lbIsExistMobile, JsonRequestBehavior.AllowGet)); }
public void InitializeTest() { _TestTransaction = new TransactionScope(); try { IRepositoryContainer educationContainer = MockRepository.GenerateMock <IRepositoryContainer>(); EducationDataContext = new EducationDataContext(); educationContainer.Expect(m => m.Obtain <IUserRepository>()).Return(new UserRepository(EducationDataContext)); educationContainer.Expect(m => m.Obtain <IEulaAgreementRepository>()).Return(new EulaAgreementRepository(EducationDataContext)); MockWindsorContainer = MockRepository.GenerateMock <IWindsorContainer>(); MockWindsorContainer.Expect(m => m.Resolve <IRepositoryContainer>()).Return(educationContainer); AccountManager = new AccountManager(MockWindsorContainer, MockRepository.GenerateMock <IEmailConfirmationManager>(), new DataTableBinder(), new UserAuditor()); MockDependecyResolver = MockRepository.GenerateMock <IDependencyResolver>(); MockDependecyResolver.Expect(m => m.GetService(typeof(IAccountManager))).Return(AccountManager); DependencyResolver.SetResolver(MockDependecyResolver); } catch (Exception) { _TestTransaction.Dispose(); _TestTransaction = null; if (EducationDataContext != null) { EducationDataContext.Dispose(); EducationDataContext = null; } throw; } }
public void GivenValidViewModelHasSelectedProviders_WhenEdit_ThenProviderAssociationsChange() { try { EducationContext.Database.ExecuteSqlCommand("Update SSD.StudentAssignedOffering Set IsActive = 0"); var expected = new int[] { 1, 2 }; ProgramModel viewModel = new ProgramModel { Id = 2, Name = "something valid", SelectedProviders = expected, SelectedServiceTypes = new List <int> { 2 } }; Target.Edit(viewModel); using (EducationDataContext assertContext = new EducationDataContext()) { var actual = assertContext.Programs.Include("ServiceOfferings.Provider").Single(p => p.Id == viewModel.Id).ServiceOfferings.Where(s => s.IsActive).Select(s => s.Provider).Distinct(); CollectionAssert.AreEquivalent(expected, actual.Select(p => p.Id).ToList()); } } finally { AssemblySetup.ForceDeleteEducationDatabase("SSD"); } }
public static void CleanupAssembly() { using (EducationDataContext context = new EducationDataContext()) { context.Database.Delete(); } }
public void GivenProviderWithApprovingStudents_WhenDelete_ThenNoApprovedProviderMappingsToDeletedProvider() { int toDeleteId; using (EducationDataContext setupContext = new EducationDataContext()) { Provider temp = new Provider { Name = "blah blah blah", IsActive = true, ApprovingStudents = setupContext.Students.ToList() }; foreach (Student student in temp.ApprovingStudents) { student.ApprovedProviders.Add(temp); } setupContext.Providers.Add(temp); setupContext.SaveChanges(); toDeleteId = temp.Id; } Target.Delete(toDeleteId); Assert.IsFalse(EducationContext.Students.Any(s => s.ApprovedProviders.Select(p => p.Id).Contains(toDeleteId))); }
public void GivenProviderWithUserAssociations_WhenDelete_ThenNoUserAssociationsToDeletedProvider() { int toDeleteId; using (EducationDataContext setupContext = new EducationDataContext()) { Provider temp = new Provider { Name = "halb halb halb", IsActive = true, UserRoles = setupContext.UserRoles.Where(u => u.Role.Name == SecurityRoles.Provider).ToList() }; foreach (UserRole userRole in temp.UserRoles) { userRole.Providers.Add(temp); } setupContext.Providers.Add(temp); setupContext.SaveChanges(); toDeleteId = temp.Id; } Target.Delete(toDeleteId); Assert.IsFalse(EducationContext.UserRoles.Any(u => u.Providers.Select(p => p.Id).Contains(toDeleteId))); }
public ActionResult CheckUserNameExist(string lsUserName) { EducationDataContext loEduContext = new EducationDataContext(); Boolean lbIsExistEmail = loEduContext.GetUserName(lsUserName); return(Json(lbIsExistEmail, JsonRequestBehavior.AllowGet)); }
public ActionResult EditProfile(UserModel loEditFormData) { EducationDataContext loEditContext = new EducationDataContext(); HttpPostedFileBase Img = loEditFormData.ProfileImg; loEditFormData.UserID = Convert.ToDecimal(Session["UserID"]); if (loEditFormData.ProfImg == null) { loEditFormData.ProfImg = img1; } loEditContext.EditProfile(loEditFormData); if (Img != null && (Img.ContentLength <= 102400 && Img.ContentType == "image/png" || Img.ContentType == "image/jpg" || Img.ContentType == "image/jpeg")) { var path = Request.PhysicalApplicationPath; string FExt = Path.GetExtension(Img.FileName); if (!Directory.Exists(path + "Uploads/Profile")) { Directory.CreateDirectory(path + "Uploads/Profile"); } System.IO.File.Delete(path + "Uploads/Profile/" + loEditFormData.FName + " " + loEditFormData.LName + loEditFormData.UserID); Img.SaveAs(path + "Uploads/Profile/" + loEditFormData.FName + " " + loEditFormData.LName + loEditFormData.UserID + FExt); Session["ProfImg"] = loEditFormData.FName + " " + loEditFormData.LName + loEditFormData.UserID + FExt; return(RedirectToAction("Index")); } else { return(RedirectToAction("Index")); } }
public ActionResult FeedBack(FeedBackModel loFeedBack, FormCollection Form) { EducationDataContext loEduContext = new EducationDataContext(); loEduContext.FeedBack(loFeedBack, Form["ContactFor"]); return(RedirectToAction("Index")); }
public void InitializeTest() { EducationContext = new EducationDataContext(); Container = AssemblySetup.CreateWindsorContainer(EducationContext); RepositoryContainer repositoryContainer = new RepositoryContainer(Container, EducationContext); Target = new ProgramManager(repositoryContainer, new DataTableBinder()); }
public void InitializeTest() { EducationContext = new EducationDataContext(); Container = AssemblySetup.CreateWindsorContainer(EducationContext); RepositoryContainer repositoryContainer = new RepositoryContainer(Container, EducationContext); Target = new PrivateHealthFieldManager(repositoryContainer, MockRepository.GenerateMock <IBlobClient>(), new DataTableBinder(), new UserAuditor()); }
public void InitializeTest() { EducationContext = new EducationDataContext(); Container = AssemblySetup.CreateWindsorContainer(EducationContext); RepositoryContainer repositoryContainer = new RepositoryContainer(Container, EducationContext); Target = new AgreementManager(repositoryContainer); }
// GET: Home public ActionResult Index() { EducationDataContext loEducontext = new EducationDataContext(); FeedBackModel loData = new FeedBackModel(); loData.loUserModel = new EducationDataContext().UserDataForIndex(); return(View("index", loData)); }
public static void InitializeAssembly(TestContext testContext) { using (EducationDataContext context = new EducationDataContext()) { context.Database.Delete(); context.Database.Initialize(true); } }
public void InitializeTest() { EducationContext = new EducationDataContext(); Container = AssemblySetup.CreateWindsorContainer(EducationContext); RepositoryContainer repositoryContainer = new RepositoryContainer(Container, EducationContext); Target = new SchoolDistrictManager(repositoryContainer, new DataTableBinder(), new UserAuditor()); User = new EducationSecurityPrincipal(EducationContext.Users.Include("UserRoles.Role").Single(u => u.UserKey == "Bob")); MockContext = MockHttpContextFactory.Create(); }
public void InitializeTest() { EducationContext = new EducationDataContext(); Container = AssemblySetup.CreateWindsorContainer(EducationContext); User = new EducationSecurityPrincipal(EducationContext.Users.Include("UserRoles.Role").Include(u => u.PrivateHealthDataViewEvents).Single(u => u.Id == 1)); RepositoryContainer repositoryContainer = new RepositoryContainer(Container, EducationContext); Target = new PublicFieldManager(repositoryContainer, MockRepository.GenerateMock <IBlobClient>(), new DataTableBinder(), new UserAuditor()); }
public ActionResult AddUser(UserModel loRegFormData) { EducationDataContext loEduContext = new EducationDataContext(); SendOTP(loRegFormData.Email); //ViewBag.Email = loRegFormData.Email; ViewBag.msg = loEduContext.UserInsert(loRegFormData); return(RedirectToAction("Confirmation")); }
public void TestInitialize() { EducationContext = new EducationDataContext(); Container = AssemblySetup.CreateWindsorContainer(EducationContext); RepositoryContainer repositoryContainer = new RepositoryContainer(Container, EducationContext); Target = new ServiceOfferingManager(repositoryContainer, new DataTableBinder()); User = new EducationSecurityPrincipal(new UserRepository(EducationContext).Items.Where(s => s.UserKey == "Bob").Include("UserRoles.Role").Single()); }
public void WhenDelete_ThenAssignedOfferingSetInactive() { Target.Delete(User, 3); using (EducationDataContext verificationContext = new EducationDataContext()) { StudentAssignedOffering actual = verificationContext.StudentAssignedOfferings.Find(3); Assert.IsFalse(actual.IsActive); } }
public ActionResult UpdatePassword(UserModel loUserData) { EducationDataContext loEduContext = new EducationDataContext(); loUserData.Email = Email; loEduContext.UpdatePassword(loUserData); OTP = null; Email = null; return(RedirectToAction("Index", "Login")); }
public void GivenMultipleSchoolIds_WhenResetApprovals_ThenNewContextCanFindNoStudentsWithApprovedProviders() { Target.ResetApprovals(new[] { 1, 3 }); Context.SaveChanges(); using (EducationDataContext assertContext = new EducationDataContext()) { Assert.IsFalse(assertContext.Students.Where(s => s.SchoolId == 1 && s.SchoolId == 3 && s.ApprovedProviders.Count() > 0).Any()); } }
public void WhenResetApprovals_ThenNewContextCanFindNoStudentsWithApprovedProviders() { Target.ResetApprovals(); Context.SaveChanges(); using (EducationDataContext assertContext = new EducationDataContext()) { Assert.IsFalse(assertContext.Students.Where(s => s.ApprovedProviders.Count() > 0).Any()); } }
public ActionResult LogoutFromAll() { EducationDataContext lsLogoutContext = new EducationDataContext(); LoginModel loCredentials = new LoginModel(); loCredentials.LoginID = Email; loCredentials.UPassword = pass; lsLogoutContext.LogOut(null, Email, pass); return(RedirectToAction("LoginCredentials", loCredentials)); }
public ActionResult UserProfile(decimal UserID = 16) { if (UserID != 0) { EducationDataContext loEduContext = new EducationDataContext(); UserProfileModel loProfile = new UserProfileModel(); loProfile.loProfileData = loEduContext.UserProfile(UserID); return(View("Profile", loProfile)); } return(RedirectToAction("Index", "Home")); }
private void CreateFavoriteServiceOfferingInDatabase(int serviceOfferingId) { using (EducationDataContext context = new EducationDataContext()) { User currentUser = context.Users.Single(u => u.UserKey == User.Identity.User.UserKey); ServiceOffering offeringToLink = context.ServiceOfferings.Single(o => o.Id == serviceOfferingId); currentUser.FavoriteServiceOfferings.Add(offeringToLink); offeringToLink.UsersLinkingAsFavorite.Add(currentUser); context.SaveChanges(); } }
public void InitializeTest() { EducationContext = new EducationDataContext(); Container = AssemblySetup.CreateWindsorContainer(EducationContext); RepositoryContainer repositoryContainer = new RepositoryContainer(Container, EducationContext); ProviderManager providerManager = new ProviderManager(repositoryContainer, new DataTableBinder()); ProgramManager programManager = new ProgramManager(repositoryContainer, new DataTableBinder()); ServiceTypeManager serviceTypeManager = new ServiceTypeManager(repositoryContainer, new DataTableBinder()); Target = new PartnersController(providerManager, programManager, serviceTypeManager); }
public void TestCleanup() { if (_TestTransaction != null) { _TestTransaction.Dispose(); } if (EducationDataContext != null) { EducationDataContext.Dispose(); } }
public ActionResult LogOut() { EducationDataContext lsLogoutContext = new EducationDataContext(); lsLogoutContext.LogOut(Session["UserID"]); Session.Clear(); Session.RemoveAll(); Session.Abandon(); ViewBag.msg = "Logged Out Successfully"; Email = pass = null; return(RedirectToAction("Index", "Homes")); }
// GET: EditProfile public ActionResult Index() { EducationDataContext EditDataContext = new EducationDataContext(); UserModel loEditProfile = new UserModel(); loEditProfile = EditDataContext.UserData(Session["UserID"]); img1 = loEditProfile.ProfImg; //loEditProfile.DoB = "08/08/1998"; //loEditProfile.dtDoB = loEditProfile.dtDoB; return(View("EditProfile", loEditProfile)); }
public static void ForceDeleteEducationDatabase(string databaseName) { using (EducationDataContext context = new EducationDataContext()) { if (context.Database.Exists()) { string dropUsersCommand = string.Format("USE [master]; ALTER DATABASE [{0}] SET SINGLE_USER WITH ROLLBACK IMMEDIATE", databaseName); context.Database.ExecuteSqlCommand(dropUsersCommand); context.Database.Delete(); } } }