Exemple #1
0
        // send kitchen notification to appropriate employee
        private async void uxGetEmployeeButton_Click(object sender, RoutedEventArgs e)
        {
            string notificationType = "Order Question";
            await PostNotificationsRequest.SendNotificationRequest(notificationType, RealmManager.All <Orders>().FirstOrDefault().employee_id, "Kitchen");

            uxOrdersPopup.IsOpen = false;
        }
Exemple #2
0
        // set all menu items to prepared
        // send notification to appropriate employee
        private async void uxCompleteOrderButton_Click(object sender, RoutedEventArgs e)
        {
            string notificationType = "Order Complete for " + c_ordersMaster.table_number_string;

            // await DecrementIngredients();
            var validUpdatePreparedRequest = await PutToPreparedRequest.SendPutToPreparedRequest(c_ordersMaster._id, c_ordersMaster.menuItems.ToList());

            await PostNotificationsRequest.SendNotificationRequest(notificationType, c_ordersMaster.employee_id, "Kitchen");

            uxOrdersPopup.IsOpen = false;
        }
Exemple #3
0
        /// <summary>
        /// Creates a new notification
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <ResultData> CreateNotificationAsync(PostNotificationsRequest request)
        {
            if (request.CaptureTime == null || string.IsNullOrEmpty(request.CountryName))
            {
                return(ErrorData(ServiceErrors.Post_CreateNotificationAsync_400_Payload));
            }

            if (await ShouldCreateNew(request))
            {
                return(SuccessData <Guid>(await _repo.CreateNotificationAsync(request)));
            }
            else
            {
                return(SuccessData <string>(string.Empty));
            }
        }
Exemple #4
0
        /// <summary>
        /// Creates a new notification
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <Guid> CreateNotificationAsync(PostNotificationsRequest request)
        {
            var id = Guid.NewGuid();
            await _notificationsDAO.CreateNotificationAsync(new NotificationDocument
            {
                Id          = id,
                CountryName = request.CountryName,
                Active      = request.IsActive,
                CapturedAt  = request.CaptureTime,
                Infections  = request.Infections,
                Deaths      = request.Deaths,
                Recovered   = request.Recovered,
                Total       = request.Infections + request.Deaths + request.Recovered
            });

            return(id);
        }
        public async Task <IActionResult> Post([FromBody] PostNotificationsRequest request)
        {
            try
            {
                var response = await _service.CreateNotificationAsync(request);

                if (response.Success)
                {
                    return(StatusCode(200, response));
                }
                else
                {
                    return(StatusCode(400, response));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(StatusCode(500, nameof(Exception)));
            }
        }
        /// <summary>
        /// Extracts infos into POST Requests payloads
        /// </summary>
        /// <param name="confirmedSituations"></param>
        /// <returns></returns>
        private void ExtractInfos(params string[] confirmedSituations)
        {
            var result    = new PostNotificationsRequest();
            var active    = confirmedSituations[0] ?? "0";
            var recovered = confirmedSituations[1] ?? "0";
            var deaths    = confirmedSituations[2] ?? "0";

            Console.WriteLine($"Posting infos for {_currentCountry}");
            Console.WriteLine($"active={active.Replace("\n", "")}; recovered={recovered.Replace("\n", "")}; deaths={deaths.Replace("\n", "")}");

            active    = active.Contains("+") ? active.IgnoreAfter("+").SanitizeCommas() : active.SanitizeCommas();
            recovered = recovered.Contains("+") ? recovered.IgnoreAfter("+").SanitizeCommas() : recovered.SanitizeCommas();
            deaths    = deaths.Contains("+") ? deaths.IgnoreAfter("+").SanitizeCommas() : deaths.SanitizeCommas();

            result.CaptureTime = DateTime.UtcNow;
            result.CountryName = _currentCountry;

            if (int.TryParse(active, out var inf))
            {
                result.Infections = inf;
            }
            if (int.TryParse(recovered, out var rec))
            {
                result.Recovered = rec;
            }
            if (int.TryParse(deaths, out var dea))
            {
                result.Deaths = dea;
            }

            result.IsActive = true;

            // Instantiates if first iteration
            if (_postRequests == null)
            {
                _postRequests = new List <PostNotificationsRequest>();
            }

            _postRequests.Add(result);
        }
Exemple #7
0
        /// <summary>
        /// Checks if differs
        /// </summary>
        /// <param name="countryName"></param>
        /// <returns></returns>
        private async Task <bool> ShouldCreateNew(PostNotificationsRequest doc)
        {
            var cases = await _repo.FindCountryCases(doc.CountryName);

            return(!cases.Any(c => c.Deaths == doc.Deaths && c.Recovered == doc.Recovered && c.Infections == doc.Infections));
        }