public void Test1() { //Arrange using (var context = new DataContext(CreateNewContextOptions())) { updatepasswordController obj = new updatepasswordController(context); emaildto obj1 = new emaildto() { Emailid = "*****@*****.**", password = "******", Confirmpassword = "******" }; //Act string checkencryptionstring="hiii how to encrypt me"; string returnencryption = updatepasswordController.Encrypt(checkencryptionstring); Task<string> result = obj.Update(obj1); //Assert Assert.IsType<string>(returnencryption); Assert.IsType<Task<string>>(result); } }
public void PostDataToAuth(string Emailid, string strNewPassword, string ConfirmPassword) { Console.WriteLine(Emailid); Console.WriteLine(strNewPassword); Console.WriteLine(ConfirmPassword); emaildto dto = new emaildto(); dto.Emailid = Emailid; dto.password = strNewPassword; dto.Confirmpassword = ConfirmPassword; // let headers = new Headers({ 'Content-Type': 'application/json' }); // let options = new RequestOptions({ headers: headers }); var client = new HttpClient(); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); AppConfig api = new AppConfig(); var result = client.PutAsync(api.serverurl + "api/updatepassword", new StringContent(JsonConvert.SerializeObject(dto), Encoding.UTF8, "application/json")); }
public async Task <string> Update([FromBody] emaildto dto) { if (_context.UserDetails.Any(x => x.Email == dto.Emailid)) { var user = _context.UserDetails.FirstOrDefault(t => t.Email == dto.Emailid); user.Email = dto.Emailid; string pswd = Encrypt(dto.password); user.PasswordHash = pswd; user.PasswordSalt = pswd; try{ _context.UserDetails.Update(user); await _context.SaveChangesAsync(); } catch (Exception ex) { throw new Exception(ex.Message); } } else { throw new Exception("Email doesn't exist"); } return(dto.Emailid); }
public void sendemail([FromBody] emaildto dto) { string email = dto.Emailid.ToLower(); Console.WriteLine("email is " + email); var check = IsValidEmail(email); bool IsValidEmail(string emailid) { try { var addr = new System.Net.Mail.MailAddress(emailid); return(addr.Address == emailid); } catch { return(false); } } if (check) { sendingmails sendEmail = new sendingmails(); sendEmail.emailsent(email); } }