public void UpdateAvailability(Availabilty item)
        {
            var oldItem = _availability.FirstOrDefault(i => i.ID == item.ID);

            if (oldItem != null)
            {
                oldItem = item;
            }
        }
 public void AddAvailability(Availabilty item)
 {
     item.ID = _availability.Last().ID + 1;
     _availability.Add(item);
 }
 public void DeleteAvailability(Availabilty item)
 {
     _availability.Remove(item);
 }
        private void Update(string day, bool state, string inTime, string outTime)
        {
            Availabilty item = _myAvailability
                .Where(p => p.Day == day)
                .FirstOrDefault();

            if (state)
            {
                if (item == null)
                {
                    DateTime dateIn, dateOut;
                    bool tryIn = DateTime.TryParse(inTime, out dateIn);
                    bool tryOut = DateTime.TryParse(outTime, out dateOut);

                    if (tryIn && tryOut)
                    {
                        Availabilty newItem = new Availabilty();
                            newItem.Day = day;
                            newItem.StartingTime = dateIn;
                            newItem.EndingTime = dateOut;
                            newItem.PersonID = App.LoggedInPerson.ID;

                        _availabilityRepository.AddAvailability(newItem);
                    }
                }
                else
                {
                    DateTime dateIn, dateOut;
                    bool tryIn = DateTime.TryParse(inTime, out dateIn);
                    bool tryOut = DateTime.TryParse(outTime, out dateOut);

                    if (tryIn && tryOut)
                    {
                        item.StartingTime = dateIn;
                        item.EndingTime = dateOut;
                        _availabilityRepository.UpdateAvailability(item);
                    }
                }
            }
            else
            {
                if (item != null)
                {
                    _availabilityRepository.DeleteAvailability(item);
                }
            }
        }