Exemplo n.º 1
0
        public static async Task <bool> UpdateEventAsync(REICTModel rEICTModel)
        {
            foreach (var @event in rEICTModel.Events)
            {
                var toUpdateEvent = (await firebase
                                     .Child("Events")
                                     .OnceAsync <Event>()).Where(a => a.Object.Id == @event.Id).FirstOrDefault();

                if (toUpdateEvent != null)
                {
                    if (CheckIfEventhasChanged(@event, toUpdateEvent))
                    {
                        await firebase
                        .Child("Events")
                        .Child(toUpdateEvent.Key)
                        .PutAsync(new Event()
                        {
                            Id               = @event.Id,
                            Description      = @event.Description.Replace(" Today", "").Replace(" Tomorrow", "").Trim(),
                            Name             = RemoveDayFormatter(@event.Name, @event.Time),
                            Time             = @event.Time,
                            FirstRespondent  = @event.FirstRespondent,
                            SecondRespondent = @event.SecondRespondent,
                            ThirdRespondent  = @event.ThirdRespondent,
                            Colour           = @event.Colour,
                            AlarmSet         = @event.AlarmSet,
                            AlarmText        = @event.AlarmText,
                            IsVisible        = @event.IsVisible
                        }).ConfigureAwait(false);
                    }
                }
                else
                {
                    await firebase
                    .Child("Events")
                    .PostAsync(new Event()
                    {
                        Id               = @event.Id,
                        Description      = @event.Description.Replace(" Today", "").Replace(" Tomorrow", "").Trim(),
                        Name             = RemoveDayFormatter(@event.Name, @event.Time),
                        Time             = @event.Time,
                        FirstRespondent  = @event.FirstRespondent,
                        SecondRespondent = @event.SecondRespondent,
                        ThirdRespondent  = @event.ThirdRespondent,
                        Colour           = @event.Colour,
                        AlarmSet         = @event.AlarmSet,
                        AlarmText        = @event.AlarmText,
                        IsVisible        = @event.IsVisible
                    }).ConfigureAwait(false);
                }
            }

            return(await Task.FromResult(true));
        }
Exemplo n.º 2
0
        public static async Task <bool> UpdatePersonAsync(REICTModel rEICTModel)
        {
            foreach (var person in rEICTModel.Persons)
            {
                var toUpdatePerson = (await firebase
                                      .Child("Persons")
                                      .OnceAsync <Person>()).Where(a => a.Object.PersonID == person.PersonID).FirstOrDefault();

                if (toUpdatePerson == null)
                {
                    await firebase
                    .Child("Persons")
                    .PostAsync(new Person()
                    {
                        PersonID   = person.PersonID,
                        Name       = person.Name,
                        Surname    = person.Surname,
                        CellNumber = person.CellNumber,
                        Password   = person.Password,
                        Role       = person.Role
                    }).ConfigureAwait(false);
                }
                else if (PersonInfoChanged(person, toUpdatePerson))
                {
                    await firebase
                    .Child("Persons")
                    .Child(toUpdatePerson.Key)
                    .PutAsync(new Person()
                    {
                        PersonID   = person.PersonID,
                        Name       = person.Name,
                        Surname    = person.Surname,
                        CellNumber = person.CellNumber,
                        Password   = person.Password,
                        Role       = person.Role
                    }).ConfigureAwait(false);
                }
            }

            return(await Task.FromResult(true));
        }
Exemplo n.º 3
0
 public static async Task <bool> AddItemAsync(REICTModel rEICTModel)
 {
     //REICTModel.Add(rEICTModel);
     await UpdateEventAsync(rEICTModel).ConfigureAwait(false);;
     return(await Task.FromResult(true));
 }