Пример #1
0
        private async Task <bool> CreateNote(string eventId, string note, string sentiment)
        {
            EventModel eventObj = await _eventRestService.GetEvent(eventId);

            if (eventObj != null && eventObj.IsEventActive)
            {
                try
                {
                    NoteModel newNote = new NoteModel()
                    {
                        EventId   = eventId,
                        Note      = note,
                        Sentiment = sentiment
                    };

                    var result = await _noteRestService.CreateNote(newNote);

                    if (!string.IsNullOrEmpty(result))
                    {
                        return(true);
                    }
                    else
                    {
                        _logger.LogError($"CreateNote: {result}");
                        return(false);
                    }
                }
                catch (Exception e)
                {
                    _logger.LogError($"UpdateEventLocationGoalValue: {e.Message}");
                    return(false);
                }
            }
            return(false);
        }
Пример #2
0
        private async Task <int> UpdateEventLocationGoalValue(string eventId, string locationId, int value)
        {
            EventModel eventObj = await _eventRestService.GetEvent(eventId);

            if (eventObj != null)
            {
                EventLocationModel eventLocation = eventObj.EventLocations?.Find(p => p.Id == locationId);
                if (eventLocation != null && eventObj.IsEventActive)
                {
                    eventLocation.GoalStatus += value;
                    try
                    {
                        var result = await _eventRestService.UpdateEvent(eventObj);

                        if (result == HttpStatusCode.OK)
                        {
                            return(eventLocation.GoalStatus);
                        }
                        else if (result == HttpStatusCode.PreconditionFailed)
                        {
                            await UpdateEventLocationGoalValue(eventId, locationId, value); //Etag error, retrying...
                        }
                        else
                        {
                            _logger.LogError($"UpdateEventLocationGoalValue: {result}");
                            return(-1);
                        }
                    }
                    catch (Exception e)
                    {
                        _logger.LogError($"UpdateEventLocationGoalValue: {e.Message}");
                        return(-1);
                    }
                }
            }
            else
            {
                _logger.LogError($"The event {eventId} wasn't found.");
            }
            return(-1);
        }
Пример #3
0
 public async Task <EventModel> GetEvent(string eventId)
 {
     return(await _eventRestService.GetEvent(eventId));
 }