Esempio n. 1
0
        private async Task <Dictionary <bool, string> > IsEntryValid(PhoneRecord record)
        {
            Dictionary <bool, string> errorMsgs = new Dictionary <bool, string> ();

            List <PhoneRecord> allRecords = await _repo.GetAllPhoneRecords();

            if (EditMode)
            {
                if (allRecords.Select(r => r.PhoneRecordId).ToList().Contains(record.PhoneRecordId))
                {
                    var recordToRemove = allRecords.Where(r => r.PhoneRecordId == record.PhoneRecordId).SingleOrDefault();
                    allRecords.Remove(recordToRemove);
                }
            }

            bool invalidIdNumber = allRecords
                                   .Where(r => r.IdentificationNumber == record.IdentificationNumber).Any();

            bool duplicateName = allRecords
                                 .Where(r => r.Name == record.Name && r.Surname == record.Surname)
                                 .Any();

            if (invalidIdNumber)
            {
                errorMsgs.Add(false, "Record was not saved. Invalid Identification Number.");
            }
            else if (duplicateName)
            {
                errorMsgs.Add(false, "Record was not saved. Duplicate name.");
            }
            return(errorMsgs);
        }
Esempio n. 2
0
        public async void LoadRecords()
        {
            allRecords = await _repo.GetAllPhoneRecords();

            Records = new ObservableCollection <PhoneRecord>(allRecords);
        }