Пример #1
0
        public IActionResult Index(long?id = 0)
        {
            ViewBag.CityList         = _lookUps.GetCity();
            ViewBag.FamilyStatusList = _lookUps.GetFamilyStatus();
            ViewBag.GenderList       = _lookUps.GetGender();
            if (id > 0)
            {
                // this is the call for update
            }
            TblPool tblPool = new TblPool();

            tblPool.Participant = 20;
            return(View(tblPool));
        }
Пример #2
0
 public string DeletePool(long Id)
 {
     try
     {
         TblPool tblPool = GetPoolById(Id);
         if (tblPool != null)
         {
             _context.Remove(tblPool);
             _context.SaveChanges();
         }
         return("");
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
Пример #3
0
        public IActionResult Index(TblPool tblPool)
        {
            if (!string.IsNullOrEmpty(tblPool.Gender))
            {
                tblPool.Gender = tblPool.Gender.Trim();
            }
            if (!string.IsNullOrEmpty(tblPool.FamilyStatus))
            {
                tblPool.FamilyStatus = tblPool.FamilyStatus.Trim();
            }
            string error = _pool.Save(tblPool);

            if (string.IsNullOrEmpty(error))
            {
                return(RedirectToAction("Poolstemplates"));
            }
            return(View());
        }
Пример #4
0
        public JsonResult GetPool(long Id = 0)
        {
            TblPool tblPool = _pool.GetPoolById(Id);

            if (tblPool != null)
            {
                return(Json(new
                {
                    status = "success",
                    data = tblPool
                }));
            }

            return(Json(new
            {
                status = "fail",
                data = ""
            }));
        }
Пример #5
0
 public string Save(TblPool tblPool)
 {
     try
     {
         if (tblPool.Id > 0)
         {
             _context.Update(tblPool);
             _context.SaveChanges();
         }
         else
         {
             _context.TblPool.Add(tblPool);
             _context.SaveChanges();
         }
         return("");
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
Пример #6
0
        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("");
        }