public bool SendEmail(string Name, RegisterUpdateModel model, string email) { if (model.status == "3") { string subject = "Registration Request Approved"; string body = "Dear " + Name + ",<br/><br/>Your registration request for Admin Profile has been approved. You can now login and go ahead with your tasks.<br/><br/>Regards,<br/>GyanSys"; string to = email; MailMessage mm = new MailMessage { From = new MailAddress("*****@*****.**") }; mm.To.Add(to); mm.Subject = subject; mm.Body = body; mm.IsBodyHtml = true; SmtpClient client = new SmtpClient("smtp.gmail.com") { UseDefaultCredentials = false, Port = 587, EnableSsl = true, Credentials = new NetworkCredential("*****@*****.**", "s/HD123gs") }; client.Send(mm); return(true); } else { string subject = "Registration Request Rejected"; string body = "Dear " + Name + ",<br/><br/>Your registration request has been rejected. Please contact Superadmin for help.<br/><br/>Regards,<br/>GyanSys"; string to = "*****@*****.**"; MailMessage mm = new MailMessage { From = new MailAddress("*****@*****.**") }; mm.To.Add(to); mm.Subject = subject; mm.Body = body; mm.IsBodyHtml = true; SmtpClient client = new SmtpClient("smtp.gmail.com") { UseDefaultCredentials = false, Port = 587, EnableSsl = true, Credentials = new NetworkCredential("*****@*****.**", "s/HD123gs") }; client.Send(mm); return(true); } }
// This method changes the approval status from applied to approved or rejected public bool ChangeStatus(int id, RegisterUpdateModel status) { var UserDetails = db.Users.FirstOrDefault(x => x.UserId == id); if (UserDetails == null) // udpate the registration request if user is found in the system { return(false); } UserDetails.Status = Convert.ToInt32(status.status); db.SaveChanges(); emailMessages.SendEmail(UserDetails.Fullname, status, UserDetails.UserEmail); // this will send auto-generated email to the user return(true); }
// This method will return true if status is updated else false if no user if found for the given user id public bool UpdateRegisterRequest(int id, RegisterUpdateModel model) { var UserDetails = db.Users.FirstOrDefault(x => x.UserId == id); if (UserDetails != null) { UserDetails.Status = Convert.ToInt32(model.status); db.SaveChanges(); superAdmin.SendEmail(UserDetails.Fullname, model, UserDetails.UserEmail); // this will send auto-generated email to the admin return(true); } return(false); }
public IHttpActionResult PutRequest(int id, RegisterUpdateModel status) { bool IsSuccess = requestApprovalRepo.ChangeStatus(id, status); return(IsSuccess ? (IHttpActionResult)Ok() : (IHttpActionResult)NotFound()); }
public IHttpActionResult PutRequest(int id, RegisterUpdateModel model) { bool IsSuccess = superAdmin.UpdateRegisterRequest(id, model); return(IsSuccess ? Ok() : (IHttpActionResult)NotFound()); }