public LoginState IsRegistered(string _strEmail, string _strPassword) { using (var context = new HUBEI_DBContext(new DbContextOptions <HUBEI_DBContext>())) { var accountWEmail = from a in context.Admin where a.Email == _strEmail select a; var account = accountWEmail.FirstOrDefault(); if (account != null) { var strAccountID = account.IdAdmin.ToString(); string strBDPW = ToHex(account.Password, false); if (!strBDPW.Equals(EncryptToMD5(_strPassword))) { return(LoginState.WRONG_PASSWORD); } } else { return(LoginState.EMAIL_NOTFOUND); } } return(LoginState.CONNECTED); }
public CompanyUnitTests() { var optionsBuilder = new DbContextOptionsBuilder <HUBEI_DBContext>(); optionsBuilder.UseInMemoryDatabase(); _context = new HUBEI_DBContext(optionsBuilder.Options); _context.District.Add(new District() { IdDistrict = 1, Description = "Margem Sul" }); _context.Company.Add(new Company() { IdCompany = 1, Description = "Esta Empresa", Name = "Empresa", Email = "*****@*****.**", IdDistrict = 1 }); _context.SaveChanges(); _controller = new CompanyController(_context, null); }
private async void InsertAdmin(Admin admin) { using (var context = new HUBEI_DBContext(new DbContextOptions <HUBEI_DBContext>())) { context.Add(admin); await context.SaveChangesAsync(); } }
public string AccountID(string strEmail) { using (var context = new HUBEI_DBContext(new DbContextOptions <HUBEI_DBContext>())) { var accoundId = from a in context.Admin where a.Email == strEmail select a; return(accoundId.FirstOrDefault().IdAdmin.ToString()); } }
public string AccountName(string _strAccountID) { using (var context = new HUBEI_DBContext(new DbContextOptions <HUBEI_DBContext>())) { var name = ""; name = (from s in context.Admin where s.IdAdmin == Int32.Parse(_strAccountID) select s.Email).FirstOrDefault().ToString(); return(name); } }
public StudentUnitTests() { var optionsBuilder = new DbContextOptionsBuilder <HUBEI_DBContext>(); optionsBuilder.UseInMemoryDatabase(); _context = new HUBEI_DBContext(optionsBuilder.Options); _controller = new BackOfficeController(_context, null); _context.StudentBranch.Add(new StudentBranch() { IdStudentBranch = 1, Description = "Ramo" }); _context.District.Add(new District() { IdDistrict = 1, Description = "Margem Sul" }); _context.Address.Add(new Address() { IdAddress = 1, PostalCode = "2475-123", Address1 = "rua", Door = "2", Locality = "Sul", IdDistrict = 1, }); _context.Student.Add(new Student() { IdStudent = 1, BirthDate = new DateTime(1999, 01, 01), Email = "*****@*****.**", IdAddress = 1, IdStudentBranch = 1, Name = "Estudante", StudentNumber = 150221066, Telephone = 911111111, }); _context.SaveChanges(); }
/// <summary> /// Populates a List with the available Project Types in the database /// </summary> /// <returns>Populated List</returns> /// <remarks></remarks> private IEnumerable <SelectListItem> PopulateProjectTypes() { using (var context = new HUBEI_DBContext(new DbContextOptions <HUBEI_DBContext>())) { List <SelectListItem> lisProjectTypes = new List <SelectListItem>(); var listProjectTypes = context.ProjectType.ToList(); foreach (ProjectType n in listProjectTypes) { lisProjectTypes.Add(new SelectListItem { Value = n.IdProjectType.ToString(), Text = n.Description }); } return(lisProjectTypes); } }
/// <summary> /// Populates a List with the available Students in the database /// </summary> /// <returns>Populated List</returns> /// <remarks></remarks> private IEnumerable <SelectListItem> PopulateStudents() { using (var context = new HUBEI_DBContext(new DbContextOptions <HUBEI_DBContext>())) { List <SelectListItem> lisStudents = new List <SelectListItem>(); var listStudents = context.Student.OrderBy(x => x.Name).ToList(); foreach (Student n in listStudents) { lisStudents.Add(new SelectListItem { Value = n.IdStudent.ToString(), Text = n.Name }); } return(lisStudents); } }
/// <summary> /// Populates a List with the available Companies in the database /// </summary> /// <returns>Populated List</returns> /// <remarks></remarks> private IEnumerable <SelectListItem> PopulateCompanies() { using (var context = new HUBEI_DBContext(new DbContextOptions <HUBEI_DBContext>())) { List <SelectListItem> lisCompanies = new List <SelectListItem>(); var listCompanies = context.Company.OrderBy(x => x.Name).ToList(); foreach (Company n in listCompanies) { lisCompanies.Add(new SelectListItem { Value = n.IdCompany.ToString(), Text = n.Name }); } return(lisCompanies); } }
public ProjectUnitTests() { var optionsBuilder = new DbContextOptionsBuilder <HUBEI_DBContext>(); optionsBuilder.UseInMemoryDatabase(); _context = new HUBEI_DBContext(optionsBuilder.Options); _controller = new ProjectController(_context, null); _context.Project.Add(new Project() { IdProject = 1, Title = "project1", Description = "Margem Sul", Report = new byte[100], ProjectDate = new DateTime(2018, 01, 01), IsVisible = true, Views = 10, Downloads = 4, Grade = 17, Video = null, IdProjectType = 1, IdCompany = 1, IdStudent = 1, IdBusinessArea = 1 }); _context.BusinessArea.Add(new BusinessArea() { IdBusinessArea = 1, Description = "Descrição do BusinessArea" }); _context.ProjectType.Add(new ProjectType() { IdProjectType = 1, Description = "Tipo1" }); _context.StudentBranch.Add(new StudentBranch() { IdStudentBranch = 1, Description = "Ramo" }); _context.Student.Add(new Student() { IdStudent = 1, BirthDate = new DateTime(), Email = "*****@*****.**", IdAddress = 1, IdStudentBranch = 1, Name = "Estudante", StudentNumber = 150221066, Telephone = 911111111, }); _context.Address.Add(new Address() { IdAddress = 1, PostalCode = "2475-123", Address1 = "rua", Door = "2", Locality = "Sul", IdDistrict = 1, }); _context.District.Add(new District() { IdDistrict = 1, Description = "Margem Sul" }); _context.Company.Add(new Company() { IdCompany = 1, Description = "Esta Empresa", Name = "Empresa", Email = "*****@*****.**", IdDistrict = 1 }); _context.SaveChanges(); }
/// <summary> /// Initializes a new instance of the <see cref="HubEI.Controllers.BackOfficeController" /> class. /// </summary> /// <param name="context">Database Context</param> /// <param name="HostingEnvironment">Hosting Environment</param> /// <remarks></remarks> public BackOfficeController(HUBEI_DBContext context, IHostingEnvironment HostingEnvironment) { _context = context; _hostingEnvironment = HostingEnvironment; }
public StatisticsUnitTests() { var optionsBuilder = new DbContextOptionsBuilder <HUBEI_DBContext>(); optionsBuilder.UseInMemoryDatabase(); _context = new HUBEI_DBContext(optionsBuilder.Options); _controller = new StatisticsController(_context, null); _context.District.Add(new District() { IdDistrict = 1, Description = "Margem Sul" }); _context.Address.Add(new Address() { IdAddress = 1, IdDistrict = 1, Address1 = "Address", Door = "23", Locality = "Baixa", PostalCode = "2835-123", }); _context.Company.Add(new Company() { IdCompany = 1, Description = "Esta Empresa", Name = "Empresa", Email = "*****@*****.**", IdDistrict = 1 }); _context.StudentBranch.Add(new StudentBranch() { IdStudentBranch = 1, Description = "Ramo" }); _context.Student.Add(new Student() { IdStudent = 1, BirthDate = new DateTime(), Email = "*****@*****.**", IdAddress = 1, IdStudentBranch = 1, Name = "Estudante", StudentNumber = 150221066, Telephone = 911111111, }); _context.Technology.Add(new Technology() { IdTechnology = 1, Description = "Tecnologia" }); _context.BusinessArea.Add(new BusinessArea() { IdBusinessArea = 1, Description = "BA", }); _context.SchoolMentor.Add(new SchoolMentor() { IdSchoolMentor = 1, Name = "Nome", Email = "*****@*****.**", }); _context.Project.Add(new Project() { IdProject = 1, Title = "project1", Description = "Margem Sul", Report = new byte[100], ProjectDate = new DateTime().Date, IsVisible = true, Views = 10, Downloads = 4, Grade = 17, Video = null, IdBusinessArea = 1 }); _context.ProjectAdvisor.Add(new ProjectAdvisor() { IdProject = 1, IdSchoolMentor = 1 }); _context.ProjectTechnology.Add(new ProjectTechnology() { IdProject = 1, IdTechnology = 1 }); _context.SaveChanges(); }
/// <summary> /// Initializes a new instance of the <see cref="HubEI.Controllers.ProjectController" /> class. /// </summary> /// <param name="context">Database Context</param> /// <param name="HostingEnvironment">Hosting Environment</param> /// <remarks></remarks> public ProjectController(HUBEI_DBContext context, IHostingEnvironment HostingEnvironment) { _context = context; _hostingEnvironment = HostingEnvironment; }
/// <summary> /// Initializes a new instance of the <see cref="HubEI.Controllers.StatisticsController" /> class. /// </summary> /// <param name="context">Database Context</param> /// <param name="HostingEnvironment">Hosting Environment</param> /// <remarks></remarks> public StatisticsController(HUBEI_DBContext context, IHostingEnvironment HostingEnvironment) { _context = context; _hostingEnvironment = HostingEnvironment; }
/// <summary> /// Initializes a new instance of the <see cref="HubEI.Controllers.CompanyController" /> class. /// </summary> /// <param name="context">Database Context</param> /// <param name="HostingEnvironment">Hosting Environment</param> /// <remarks></remarks> public CompanyController(HUBEI_DBContext context, IHostingEnvironment HostingEnvironment) { _context = context; _hostingEnvironment = HostingEnvironment; }