Beispiel #1
0
        private MailMessage GetMailMessage(SurveyCompletionParent surveyCompletionParent, string attachmentFileName)
        {
            var mailMessage = new MailMessage();

            mailMessage.To.Add(new MailAddress(surveyCompletionParent.Company.ComercialContact.Email));
            mailMessage.From    = new MailAddress(ConfigurationManager.AppSettings["SMTPUsername"]);
            mailMessage.Subject = "Evaluando Software - Proceso Incompleto";

            var link = string.Format("{0}://{1}/Product/Evaluation/RegisterContinue?surveyCompletionId={2}&partialSaveKey={3}",
                                     HttpContext.Current.Request.Url.Scheme,
                                     HttpContext.Current.Request.Url.Host,
                                     surveyCompletionParent.Id,
                                     surveyCompletionParent.PartialSaveKey);

            mailMessage.Body  = string.Format("<p>Gracias por registrar su producto/servicio en Evaluando Software. Para poder continuar con el registro de su producto/servicio debe acceder al siguiente link: {0}</p>", link);
            mailMessage.Body += "<p>Adjunto encontrar&aacute; un PDF con informaci&oacute;n registrada hasta el momento.</p>";

            mailMessage.IsBodyHtml = true;

            var attachment = new Attachment(attachmentFileName, MediaTypeNames.Application.Pdf);

            mailMessage.Attachments.Add(attachment);

            return(mailMessage);
        }
        private MailMessage GetMailMessage(SurveyCompletionParent surveyCompletionParent, string attachmentFileName)
        {
            var mailMessage = new MailMessage();

            mailMessage.To.Add(new MailAddress(surveyCompletionParent.Company.ComercialContact.Email));
            mailMessage.From    = new MailAddress(ConfigurationManager.AppSettings["SMTPUsername"]);
            mailMessage.Subject = "Evaluando Software - Registro de Producto/Servicio Aprobado";

            var link = string.Format("{0}://{1}/Product/Evaluation/RegisterContinue?surveyCompletionId={2}&partialSaveKey={3}",
                                     HttpContext.Current.Request.Url.Scheme,
                                     HttpContext.Current.Request.Url.Host,
                                     surveyCompletionParent.Id,
                                     surveyCompletionParent.PartialSaveKey);

            mailMessage.Body  = "Estimado " + surveyCompletionParent.Company.ComercialContact.FullName + ":<br><br>";
            mailMessage.Body  = "<p>El producto/servicio ha sido de aprobado. <br /> A partir de ahora aparecer&aacute; en los informes de nuestras evaluaciones.</p>";
            mailMessage.Body += string.Format("<p>En caso de querer realizar alguna modificaci&oacute;n sobre el registro, podr&aacute; hacerlo desde la web</p>");
            mailMessage.Body += "<br><br> Lo saluda atentamente, <br>el equipo de <a href='evaluandosoftware.com' target='_blank'>EvaluandoSoftware.com</a>";

            mailMessage.IsBodyHtml = true;

            var attachment = new Attachment(attachmentFileName, MediaTypeNames.Application.Pdf);

            mailMessage.Attachments.Add(attachment);

            return(mailMessage);
        }
        public void Send(string attachmentFileName, SurveyCompletionParent surveyCompletionParent)
        {
            var companyMailMessage = this.GetCompanyMailMessage(surveyCompletionParent, attachmentFileName);
            var adminMailMessage   = this.GetAdminMailMessage(attachmentFileName, surveyCompletionParent);

            this.emailSender.Send(companyMailMessage);
            this.emailSender.Send(adminMailMessage);
        }
Beispiel #4
0
        public string GetLink(SurveyCompletionParent surveyCompletionParent)
        {
            var link = string.Format("{0}/Continue?Category={1}&ParentSurveyCompletionId={2}&PartialSaveKey={3}",
                                     ConfigurationManager.AppSettings["URL"],
                                     surveyCompletionParent.Category.Id,
                                     surveyCompletionParent.Id,
                                     surveyCompletionParent.PartialSaveKey);

            return(link);
        }
        private MailMessage GetAdminMailMessage(string attachmentFileName, SurveyCompletionParent surveyCompletionParent)
        {
            var email   = ConfigurationManager.AppSettings["SMTPUsername"];
            var subject = "Oferta pendiente de autorización";
            var body    = $"La empresa {surveyCompletionParent.Company.CompanyName} ingresó un nuevo producto/ servicio {surveyCompletionParent.Product.Name}";

            MailMessage mailMessage = new MailMessage(email, email, subject, body)
            {
                IsBodyHtml = true
            };

            var attachment = new Attachment(attachmentFileName, MediaTypeNames.Application.Pdf);

            mailMessage.Attachments.Add(attachment);

            return(mailMessage);
        }
        private MailMessage GetMailMessage(SurveyCompletionParent surveyCompletionParent)
        {
            var link  = this.sendEmailToContinueService.GetLink(surveyCompletionParent);
            var email = ConfigurationManager.AppSettings["SMTPUsername"];

            var reminderCount = surveyCompletionParent.PartialSaveReminderCount + 1;
            var subject       = $"Evaluando Software - Proyecto no finalizado (Reminder {reminderCount}/4)";

            string body = string.Format("Su proyecto para obtener una recomencación está pendiente de finalización. Ingresando al siguiente link {0}, podrás terminarlo y recibir la recomendación de producto/ servicio que mejor se adapte a tus necesidades. <br /> <br /> Este servicio forma parte del Programa de Mejoramiento de la Industria, una herramienta de Evaluando Software para mejorar las condiciones de oferta y demanda. Para ti es gratuito", (object)link);

            MailMessage mailMessage = new MailMessage(email, email, subject, body)
            {
                IsBodyHtml = true
            };

            return(mailMessage);
        }
        private MailMessage GetCompanyMailMessage(SurveyCompletionParent surveyCompletionParent, string attachmentFileName)
        {
            var mailMessage = new MailMessage();

            mailMessage.To.Add(new MailAddress(surveyCompletionParent.Company.ComercialContact.Email));
            mailMessage.From    = new MailAddress(ConfigurationManager.AppSettings["SMTPUsername"]);
            mailMessage.Subject = "Evaluando Software - Registro de Producto/Servicio";

            mailMessage.Body  = "Estimado " + surveyCompletionParent.Company.ComercialContact.FullName + ":<br><br>";
            mailMessage.Body  = "<p>Gracias por registrar su producto/servicio en Evaluando Software. El mismo se encuentra pendiente de aprobaci&oacute;n para aparecer en los resultados de nuestras evaluaciones.</p>";
            mailMessage.Body += "<p>Adjunto encontrar&aacute; un PDF con informaci&oacute;n registrada.</p>";
            mailMessage.Body += "<br><br> Lo saluda atentamente, <br>el equipo de <a href='evaluandosoftware.com' target='_blank'>EvaluandoSoftware.com</a>";

            mailMessage.IsBodyHtml = true;

            var attachment = new Attachment(attachmentFileName, MediaTypeNames.Application.Pdf);

            mailMessage.Attachments.Add(attachment);

            return(mailMessage);
        }
        private App.Models.Oferta.RegisterViewModel CompanyRegisterViewModelMap(SurveyCompletionParent surveyCompletion, int surveyCompletionId)
        {
            var model = new App.Models.Oferta.RegisterViewModel
            {
                SurveyCompletionId       = surveyCompletionId,
                CompanyName              = surveyCompletion.Company.CompanyName,
                CompanyDescription       = surveyCompletion.Company.CompanyDescription,
                CompanyWebSite           = surveyCompletion.Company.CompanyWebSite,
                CompanyCountry           = surveyCompletion.Company.CompanyCountry,
                CompanyCity              = surveyCompletion.Company.CompanyCity,
                CompanyAddress           = surveyCompletion.Company.CompanyAddress,
                CompanyPostalCode        = surveyCompletion.Company.CompanyPostalCode,
                CompanyBranchOfficesIn   = surveyCompletion.Company.CompanyBranchOfficesIn,
                CompanyFiscalStartDate   = surveyCompletion.Company.CompanyFiscalStartDate,
                CompanyFiscalEndDate     = surveyCompletion.Company.CompanyFiscalEndDate,
                CompanyPeopleInCompany   = surveyCompletion.Company.CompanyPeopleInCompany,
                ComercialContactFullName = surveyCompletion.Company.ComercialContact.FullName,
                ComercialContactPosition = surveyCompletion.Company.ComercialContact.Position,
                ComercialContactPhone    = surveyCompletion.Company.ComercialContact.Phone,
                ComercialContactEmail    = surveyCompletion.Company.ComercialContact.Email
            };

            return(model);
        }
        private MailMessage GetMailMessage(SurveyCompletionParent surveyCompletionParent, string attachmentFileName)
        {
            var mailMessage = new MailMessage();

            mailMessage.To.Add(new MailAddress(surveyCompletionParent.Company.ComercialContact.Email));
            mailMessage.From    = new MailAddress(ConfigurationManager.AppSettings["SMTPUsername"]);
            mailMessage.Subject = "Evaluando Software - Actualización de producto/servicio";

            var link = string.Format("{0}/Product/Evaluation/RegisterContinue?surveyCompletionId={1}&partialSaveKey={2}",
                                     ConfigurationManager.AppSettings["URL"],
                                     surveyCompletionParent.Id,
                                     surveyCompletionParent.PartialSaveKey);

            mailMessage.Body  = string.Format("<p>La ultima actualizaci&oacute;n de su producto/servicio fue realizada hace 6 meces, le pedimos por favor ingrese al siguiente link para actualizar la información del mismo: {0}</p>", link);
            mailMessage.Body += "<p>Adjunto encontrar&aacute; un PDF con informaci&oacute;n registrada hasta el momento.</p>";

            mailMessage.IsBodyHtml = true;

            var attachment = new Attachment(attachmentFileName, MediaTypeNames.Application.Pdf);

            mailMessage.Attachments.Add(attachment);

            return(mailMessage);
        }
Beispiel #10
0
        private SurveyCompletionParent InsertSurveyCompletion(SurveyViewModel model, bool partial)
        {
            var category = this.modelContext
                           .Categories
                           .Where(x => x.Id == model.CategoryId)
                           .FirstOrDefault();

            var role = this.roleManager.FindByName("DEMANDA");

            var surveyCompletionParent = new SurveyCompletionParent
            {
                Product        = null,
                Role           = role,
                Status         = "Aprobado",
                PartialSave    = partial,
                Category       = category,
                Email          = model.Email,
                PartialSaveKey = Guid.NewGuid().ToString()
            };

            foreach (var survey in model.SurveyDTOs)
            {
                var surveyCompletion = new SurveyCompletion
                {
                    SurveyId    = survey.SurveyId,
                    CategoryId  = survey.CategoryId,
                    Category    = survey.CategoryName,
                    Email       = model.Email,
                    Role        = role,
                    Parent      = surveyCompletionParent,
                    PartialSave = partial
                };

                var surveyQuestions = this.modelContext
                                      .Questions
                                      .Include("Answers")
                                      .Where(x => x.Survey.Id == survey.SurveyId)
                                      .ToList();

                foreach (var question in model.surveyCompletionDTOs)
                {
                    var answers = new List <SurveyCompletionAnswer>();
                    if (question.SurveyId == survey.SurveyId)
                    {
                        if (question.Answers != null)
                        {
                            answers = surveyQuestions
                                      .Where(x => x.Id == question.QuestionId)
                                      .FirstOrDefault()
                                      .Answers
                                      .Where(x => question.Answers.Contains(x.Id))
                                      .Select(x => new SurveyCompletionAnswer
                            {
                                Answer      = x.DemandAnswer,
                                AnswerValue = x.Value
                            })
                                      .ToList();
                        }

                        string          currentUserId = User.Identity.GetUserId();
                        ApplicationUser currentUser   = this.modelContext.Users.FirstOrDefault(x => x.Id == currentUserId);

                        var surveyCompletionQuestion = new SurveyCompletionQuestion
                        {
                            Question   = question.Question,
                            QuestionId = question.QuestionId,
                            Answers    = answers
                        };

                        surveyCompletion.Questions.Add(surveyCompletionQuestion);
                    }
                }

                this.modelContext.SurveysCompletion.Add(surveyCompletion);
            }

            this.modelContext.SurveyCompletionParent.Add(surveyCompletionParent);
            this.modelContext.SaveChanges();

            return(surveyCompletionParent);
        }
        private void SendEmail(SurveyCompletionParent surveyCompletionParent)
        {
            var mailMessage = this.GetMailMessage(surveyCompletionParent);

            this.emailSender.Send(mailMessage);
        }
        private SurveyCompletionParent InsertSurveyCompletion(SurveyViewModel model, bool partial = false)
        {
            this.RemovePartialSurveyCompletion(model);

            var category = this.modelContext
                           .Categories
                           .Where(x => x.Id == model.CategoryId)
                           .FirstOrDefault();

            var userId = User.Identity.GetUserId();
            var role   = this.roleManager.FindByName("OFERTA");

            var user = this.modelContext
                       .Users
                       .FirstOrDefault(x => x.Id == userId);

            var company = this.modelContext
                          .Companies
                          .Include("ComercialContact")
                          .FirstOrDefault(x => x.Id == model.CompanyId);
            //aca  crear el pridcuto con el contactro del producto
            var producto = new Product
            {
                Name           = model.ProductName,
                Description    = model.ProductDescription,
                WebSite        = model.ProductWebSite,
                Version        = model.ProductVersion,
                User           = user,
                ProductContact = new Contact
                {
                    FullName = model.ProductContactFullName,
                    Position = model.ProductContactPosition,
                    Phone    = model.ProductContactPhone,
                    Email    = model.ProductContactEmail
                }
            };

            producto.Company = company;
            modelContext.Products.Add(producto);
            modelContext.SaveChanges();

            var surveyCompletionParent = new SurveyCompletionParent(company)
            {
                Product     = producto,
                Role        = role,
                Status      = "Pendiente",
                PartialSave = partial,
                Category    = category
            };

            foreach (var surveyDTO in model.SurveyDTOs)
            {
                var categoryObj = this.modelContext
                                  .Categories
                                  .Where(x => x.Id == surveyDTO.CategoryId)
                                  .FirstOrDefault();

                var surveyCompletion = new SurveyCompletion(company)
                {
                    SurveyId    = surveyDTO.SurveyId,
                    CategoryId  = surveyDTO.CategoryId,
                    Product     = producto,
                    Category    = surveyDTO.CategoryName,
                    CategoryObj = categoryObj,
                    Role        = role,
                    PartialSave = partial,
                    Parent      = surveyCompletionParent
                };

                var surveyQuestions = this.modelContext
                                      .Questions
                                      .Include("Answers")
                                      .Where(x => x.Survey.Id == surveyDTO.SurveyId)
                                      .ToList();

                foreach (var question in model.surveyCompletionDTOs)
                {
                    var answers = new List <SurveyCompletionAnswer>();

                    if (question.SurveyId == surveyDTO.SurveyId)
                    {
                        if (question.Answers != null)
                        {
                            answers = surveyQuestions
                                      .Where(x => x.Id == question.QuestionId)
                                      .FirstOrDefault()
                                      .Answers
                                      .Where(x => question.Answers.Contains(x.Id))
                                      .Select(x => new SurveyCompletionAnswer
                            {
                                Answer      = x.SupplyAnswer,
                                AnswerValue = x.Value
                            })
                                      .ToList();
                        }

                        string          currentUserId = User.Identity.GetUserId();
                        ApplicationUser currentUser   = this.modelContext.Users.FirstOrDefault(x => x.Id == currentUserId);

                        var surveyCompletionQuestion = new SurveyCompletionQuestion
                        {
                            Question   = question.Question,
                            QuestionId = question.QuestionId,
                            Answers    = answers
                        };

                        surveyCompletion.Questions.Add(surveyCompletionQuestion);
                    }
                }

                this.modelContext.SurveysCompletion.Add(surveyCompletion);
            }
            this.modelContext.SurveyCompletionParent.Add(surveyCompletionParent);
            this.modelContext.SaveChanges();

            return(surveyCompletionParent);
        }
        public void Send(string attachmentFileName, SurveyCompletionParent surveyCompletionParent)
        {
            var mailMessage = this.GetMailMessage(surveyCompletionParent, attachmentFileName);

            this.emailSender.Send(mailMessage);
        }