public UserRepository(UserManager <AppUser> userManager, IMapper mapper, VCDbContext db) : base(db) { _userManager = userManager; _mapper = mapper; }
public IHttpActionResult SendMail(string id, string toEmail, string doctorName, string mobile) { try { string fromAddress = ConfigurationManager.AppSettings["fromEmail"]; string toAddress = toEmail; string fromPassword = ConfigurationManager.AppSettings["fromPassword"]; string subject = "Doctor Confirmation Email"; string body = "Sir,<br/> Please confirm if " + doctorName + " having Mobile No " + mobile + " is working in your hospital.<br/><br/><b>Regards<br/>Online Veterinary Care System</b>"; var smtp = new System.Net.Mail.SmtpClient { Host = "smtp.gmail.com", Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, Credentials = new NetworkCredential(fromAddress, fromPassword), Timeout = 20000 }; using (var message = new MailMessage(fromAddress, toAddress) { Subject = subject, Body = body, IsBodyHtml = true }) { smtp.Send(message); } VCDbContext _context = new VCDbContext(); Guid actualId = Guid.Parse(id); var user = _context.Users.FirstOrDefault(u => u.ID == actualId); if (user != null) { user.ConfirmationMailSent = true; _context.SaveChanges(); } return(Ok("Confirmation Email Sent.")); } catch (Exception ex) { return(Ok("Error occured. " + ex.Message)); } }
protected BaseRepository(VCDbContext db) { Db = db; }