Ejemplo n.º 1
0
        private void SendPushNotification(SendInfo _info, string _city, string _todayForecast, string _currentObservation, string _riskDescription)
        {
            string _msg1 = string.Format("Your genetically tailored forecast for {0}: {1} Right now it's {2}. {3}",
                                         _city, _todayForecast, _currentObservation, _riskDescription);

            notificationService.Send(_info.Id, _msg1);
        }
Ejemplo n.º 2
0
        public void Can_send_push_notification_iOS()
        {
            PushNotificationService.ShouldNotBeNull();

            var items = new List <iOSUserDevice>
            {
                new iOSUserDevice()
            };

            var result = PushNotificationService.Send("Title", "Geeks push notification", items);

            result.ShouldBeTrue();
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> PutSurvey(int id, SurveyDto survey, bool activate = false)
        {
            var errorDictionary = ValidateSurveyForm(survey);

            if (errorDictionary.Count > 0)
            {
                return(BadRequest(new { errors = errorDictionary, code = 400 }));
            }

            var model = survey.Adapt <Survey>();

            model.Id = id;
            model.ModificationDate      = DateTime.Now;
            _context.Entry(model).State = EntityState.Modified;
            model.CreatorId             = int.Parse(User.FindFirstValue(ClaimTypes.Name));
            model.Active = activate;

            var oldQuestions = await _context.Questions.Where(x => x.SurveyId == id).ToListAsync();

            _context.Questions.RemoveRange(oldQuestions);
            await _context.SaveChangesAsync();

            foreach (var question in model.Questions)
            {
                question.Id = null;
            }

            await _context.Questions.AddRangeAsync(model.Questions);

            await _context.SaveChangesAsync();

            var addedSurvey = await GetSurvey(model.Id.Value);

            if (activate)
            {
                await _pushNotificationService.Send("New survey", $"New survey {addedSurvey.Value.Name} linked to your course {addedSurvey.Value.CourseName} has been added!", addedSurvey.Value.CourseSemesterName + addedSurvey.Value.CourseName);
            }
            return(Ok());
        }