public ActionResult Create(SS_SolicitudServicio ss_solicitudservicio) { if (ModelState.IsValid) { db.SS_SolicitudServicio.Add(ss_solicitudservicio); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.AN_Id = new SelectList(db.AN_Anuncios, "AN_Id", "AN_Titulo", ss_solicitudservicio.AN_Id); ViewBag.ST_Id = new SelectList(db.ST_Estatus, "ST_Id", "ST_Descripcion", ss_solicitudservicio.ST_Id); return View(ss_solicitudservicio); }
private void SendEmailNotification(SS_SolicitudServicio solicitud, bool isReview) { string pXml = string.Empty; var ppEmailTemplate = new Notification(); var userName = WebSecurity.CurrentUserName; using (db = new Entities()) { var soli = db.SS_SolicitudServicio.Where(c => c.SS_Id == solicitud.SS_Id); ppEmailTemplate.CustomerName = soli.FirstOrDefault().UserProfile.Name; ppEmailTemplate.ProviderName = soli.FirstOrDefault().AN_Anuncios.UserProfile.Name; ppEmailTemplate.SolicitudId = soli.FirstOrDefault().SS_Id; ppEmailTemplate.AnuncioId = soli.FirstOrDefault().AN_Anuncios.AN_Id; ppEmailTemplate.EmailCliente = soli.FirstOrDefault().UserProfile.UserName; ppEmailTemplate.EmailProveedor = soli.FirstOrDefault().AN_Anuncios.UserProfile.UserName; string urlimg = Request.Url.GetLeftPart(UriPartial.Authority) + VirtualPathUtility.ToAbsolute("~/"); var firstImage = "~/Images/logo2-blue.png"; var formatted = firstImage.Replace("~", ""); if (formatted.StartsWith("/")) formatted = formatted.Remove(0, 1); firstImage = urlimg + formatted; ppEmailTemplate.Image = firstImage; string link = Request.Url.GetLeftPart(UriPartial.Authority) + VirtualPathUtility.ToAbsolute("~/") + "Review/Create/" + solicitud.SS_Id; ppEmailTemplate.LinkReview = link; pXml = ppEmailTemplate.Serialize<Notification>(); string serverPath = string.Empty; serverPath = base.Server.MapPath("~"); string body = string.Empty; if (isReview) { body = pXml.ConvertXML(Path.Combine(serverPath, @"EmailTemplates\ServicioReview.xslt")); Extensions.ExtensionHelper.SendEmail(ppEmailTemplate.EmailCliente, "Informanos de como te fue en el servicio", body); var soliupdate = db.SS_SolicitudServicio.Find(solicitud.SS_Id); soliupdate.ST_Id = 4; db.Entry(soliupdate).State = EntityState.Modified; db.SaveChanges(); } else { body = pXml.ConvertXML(Path.Combine(serverPath, @"EmailTemplates\ServicioRequestClient.xslt")); Extensions.ExtensionHelper.SendEmail(ppEmailTemplate.EmailCliente, "Solicitud de Servicio", body); body = pXml.ConvertXML(Path.Combine(serverPath, @"EmailTemplates\ServicioRequestProved.xslt")); Extensions.ExtensionHelper.SendEmail(ppEmailTemplate.EmailProveedor, "Solicitud de Servicio", body); } } }