public void RatingTest() { var optionsBuilder = new DbContextOptionsBuilder <IGContext>(); optionsBuilder.UseInMemoryDatabase("IELTS_GiaSu"); var dbContext = new IGContext(optionsBuilder.Options); var dateTime = DateTime.UtcNow; var ratingObj = new IG_Rating_Login_Service { feedback = "Hệ thống tốt", loginToken = MD5Generator.CreateMD5(dateTime.ToString()), timestamp = dateTime, serviceCode = "IG_VeSinh", ratingPoint = 5 }; dbContext.IG_Rating_Login_Service.Add(ratingObj); var result = dbContext.SaveChanges(); if (result > 0) { Assert.Pass(); } else { Assert.Fail(); } }
public async Task <IActionResult> Login(string serviceCode, string passcode) { var getService = await unitOfWork.IG_ServiceRepository.Get_IG_Service(serviceCode, passcode); if (getService != null) { var loginService = new IG_Login_Service { serviceCode = serviceCode, timestamp = DateTime.UtcNow, }; loginService.loginToken = MD5Generator.CreateMD5(loginService.timestamp.ToString()); unitOfWork.IG_Login_ServiceRepository.Add(loginService); unitOfWork.Save(); HttpContext.Session.SetString(Constant_Login.LOGINTOKEN, loginService.loginToken); HttpContext.Session.SetString(Constant_Login.SERVICE, loginService.serviceCode); return(Ok(getService)); } return(NotFound()); }