public string SendSurvey(TblPoolSurvey tblPoolSurvey) { long?poolId = 0; if (tblPoolSurvey.IsNewTemplate == true) { tblPoolSurvey.PoolTemplate.Id = 0; _pool.Save(tblPoolSurvey.PoolTemplate, ref poolId); } else { poolId = tblPoolSurvey.PoolTemplateId; } tblPoolSurvey.Survey.Participants = tblPoolSurvey.PoolTemplate.Participant; tblPoolSurvey.Survey.CreatedDate = System.DateTime.Now; long id = AddSurvey(tblPoolSurvey.Survey); TblPoolSurvey poolSurvey = new TblPoolSurvey(); poolSurvey.Id = 0; poolSurvey.SurveyId = id; poolSurvey.PoolTemplateId = poolId; poolSurvey.CreatedDate = DateTime.Now; long poolSurveyId = addJunctionEntery(poolSurvey); List <TblUser> tblUsers; if (tblPoolSurvey.PoolTemplate.AgeMin == null) { tblUsers = _context.TblUser.FromSqlRaw("SearchUserSurvey @p0, @p1, @p2, @p3, @p4, @p5, @p6", tblPoolSurvey.PoolTemplate.Participant, "", "", tblPoolSurvey.PoolTemplate.CityIds, tblPoolSurvey.PoolTemplate.Gender, tblPoolSurvey.PoolTemplate.FamilyStatus, null).ToList(); } else { tblUsers = _context.TblUser.FromSqlRaw("SearchUserSurvey @p0, @p1, @p2, @p3, @p4, @p5, @p6", tblPoolSurvey.PoolTemplate.Participant, tblPoolSurvey.PoolTemplate.AgeMin, tblPoolSurvey.PoolTemplate.AgeMax, tblPoolSurvey.PoolTemplate.CityIds, tblPoolSurvey.PoolTemplate.Gender, tblPoolSurvey.PoolTemplate.FamilyStatus, null).ToList(); } // var tblUsers = _context.Database.ExecuteSqlCommand("SearchUserSurvey @p0,@p1,@p2,@p3,@p4,@p5", 1,10,45,null,null,null).ToList(); foreach (var item in tblUsers) { SendToUser(id, poolSurveyId, item.Id); } string htmlString = ESS.SFS.Helper.Common.SendToSurveyHtml; htmlString = htmlString.Replace("[SurveyName]", tblPoolSurvey.Survey.Title); string body = ""; foreach (var item in tblUsers) { body = htmlString.Replace("[Name]", item.FullName); ESS.SFS.Helper.Common.sendEmailFromAWS(body, "New Smart Family Survey Received", item.Username, ""); } return(""); }
public IActionResult Index() { ViewBag.FormList = _form.GetForms(); ViewBag.PoolList = _pool.GetPools(); ViewBag.CityList = _lookUps.GetCity(); ViewBag.FamilyStatusList = _lookUps.GetFamilyStatus(); ViewBag.GenderList = _lookUps.GetGender(); TblPoolSurvey tblPoolSurvey = new TblPoolSurvey(); tblPoolSurvey.PoolTemplate = new TblPool(); tblPoolSurvey.PoolTemplate.Participant = 20; return(View()); }
public IActionResult Index(TblPoolSurvey tblPoolSurvey) { if (!string.IsNullOrEmpty(tblPoolSurvey.PoolTemplate.Gender)) { tblPoolSurvey.PoolTemplate.Gender = tblPoolSurvey.PoolTemplate.Gender.Trim(); } if (!string.IsNullOrEmpty(tblPoolSurvey.PoolTemplate.FamilyStatus)) { tblPoolSurvey.PoolTemplate.FamilyStatus = tblPoolSurvey.PoolTemplate.FamilyStatus.Trim(); } _survey.SendSurvey(tblPoolSurvey); ViewBag.FormList = _form.GetForms(); ViewBag.PoolList = _pool.GetPools(); ViewBag.CityList = _lookUps.GetCity(); ViewBag.FamilyStatusList = _lookUps.GetFamilyStatus(); ViewBag.GenderList = _lookUps.GetGender(); return(RedirectToAction("successScreen")); }
public string SendSurveyFromPool(long surveyId, long PoolId, string ids, TblPool tblPool) { TblPoolSurvey poolSurvey = new TblPoolSurvey(); poolSurvey.Id = 0; poolSurvey.SurveyId = surveyId; poolSurvey.PoolTemplateId = PoolId; poolSurvey.CreatedDate = DateTime.Now; long poolSurveyId = addJunctionEntery(poolSurvey); List <TblUser> tblUsers; if (tblPool.AgeMin == null) { tblUsers = _context.TblUser.FromSqlRaw("SearchUserSurvey @p0, @p1, @p2, @p3, @p4, @p5, @p6", tblPool.Participant, "", "", tblPool.CityIds, tblPool.Gender, tblPool.FamilyStatus, ids).ToList(); } else { tblUsers = _context.TblUser.FromSqlRaw("SearchUserSurvey @p0, @p1, @p2, @p3, @p4, @p5, @p6", tblPool.Participant, tblPool.AgeMin, tblPool.AgeMax, tblPool.CityIds, tblPool.Gender, tblPool.FamilyStatus, ids).ToList(); } foreach (var item in tblUsers) { SendToUser(surveyId, poolSurveyId, item.Id); } string htmlString = ESS.SFS.Helper.Common.SendToSurveyHtml; var tblSurvey = _context.TblSurvey.Find(surveyId); htmlString = htmlString.Replace("[SurveyName]", tblSurvey.Title); string body = ""; foreach (var item in tblUsers) { body = htmlString.Replace("[Name]", item.FullName); ESS.SFS.Helper.Common.sendEmailFromAWS(body, "New Smart Family Survey Received", item.Username, ""); } return(""); }
private long addJunctionEntery(TblPoolSurvey poolSurvey) { _context.TblPoolSurvey.Add(poolSurvey); _context.SaveChanges(); return(poolSurvey.Id); }