public SingleResponseOut <UserViewModel> ShowInterestOnPlan(int id) { using (PortalEntities _context = new PortalEntities()) { SingleResponseOut <UserViewModel> responseOut = new SingleResponseOut <UserViewModel>(); var data = _context.portal_user.Where(x => x.pk_user_id == id).Select(x => new UserViewModel { user_name = x.user_name, firstname = x.firstname, contact = x.contact, email = x.email }).FirstOrDefault(); responseOut.Model = data; return(responseOut); } }
public JsonResult ShowInterestOnPlan(string plan) { SingleResponseOut <UserViewModel> responseOut = new SingleResponseOut <UserViewModel>(); IVendorBL vendorBL = new VendorEngine(); int user_id = Convert.ToInt32(HttpContext.Session[SessionKey.CurrentUserID]); responseOut = vendorBL.ShowInterestOnPlan(user_id); string body = string.Empty; //using streamreader for reading my htmltemplate using (StreamReader reader = new StreamReader(Server.MapPath("~/EmailTemplates/VendorInterestPlan.html"))) { body = reader.ReadToEnd(); if (plan == "Walker") { body = body.Replace("{plan}", plan); } if (plan == "Runner") { body = body.Replace("{plan}", plan); } if (plan == "NotSure") { body = body.Replace("{plan}", plan); } body = body.Replace("{name}", responseOut.Model.firstname); body = body.Replace("{mobile}", responseOut.Model.contact); body = body.Replace("{Email}", responseOut.Model.email); bool status = Utilities.SendEmail("", "*****@*****.**", "Codelate | Interest Request from Vendor!", body, 587, true, "smtp.gmail.com", "", null, null); if (status) { responseOut.message = "Email Sent !"; responseOut.status = ActionStatus.Success; } else { responseOut.message = "Email Not Sent !"; responseOut.status = ActionStatus.Fail; } } return(Json(responseOut, JsonRequestBehavior.AllowGet)); }