public void Test_FindByID_Employee() { var repository = new EmployeesRepository(); var employee = repository.FindById(1, connection); Assert.IsNotNull(employee); }
public ActionResult Login(string employeeID, string phone) { var cookieName = "Employee"; var employeesRepository = new EmployeesRepository(); var id = 0; int.TryParse(employeeID, out id); var employee = employeesRepository.FindById(id); if (employee != null) { if (id == employee.EmployeeID && phone == employee.Phone) { if (Response.Cookies.AllKeys.Contains(cookieName)) { return(RedirectToAction("Home", "R7Company")); } //var token = Guid.NewGuid().ToString(); //HttpContext.Application[token] = DateTime.UtcNow.AddHours(12); var hc = new HttpCookie(cookieName, HttpUtility.UrlEncode(employee.EmployeeID.ToString())) { Expires = DateTime.Now.AddMinutes(30), HttpOnly = true }; Response.Cookies.Add(hc); return(RedirectToAction("Home", "R7Company")); } } return(RedirectToAction("Index", "R7Company")); //if (member != null) //{ // if (memberid == member.MemberID && password == member.Password) // { // if (Response.Cookies.AllKeys.Contains(cookieName)) // { // var cookieVal = Response.Cookies[cookieName].Value; // HttpContext.Application.Remove(cookieVal); // Response.Cookies.Remove(cookieName); // } // var token = Guid.NewGuid().ToString(); // //HttpContext.Application[token] = DateTime.UtcNow.AddHours(12); // var user = new User() // { // UserID = member.MemberID, // Username = member.Name // }; // string json = JSONSerializer.Serialize(user); // var hc = new HttpCookie(cookieName, HttpUtility.UrlEncode(json)) // { // Expires = DateTime.Now.AddMinutes(20), // HttpOnly = true // }; // Response.Cookies.Add(hc); // } //} //return RedirectToAction("Index", "Home"); }
public void Employees_Update() { var repository = new EmployeesRepository(); Employees employee = new Employees() { EmployeeID = 1, Name = "洪識超1", Phone = "0123456789", HireDate = new DateTime(1996, 06, 01), }; repository.Update(employee, connection); var employees = repository.FindById(1, connection); Assert.IsTrue(employees.Name == "洪識超1"); }
public async Task <Employees> GetEmployeeDetailsAsync(long employeeId) { return(await EmployeesRepo.FindById(employeeId)); }