void AddLicence() { if (string.IsNullOrEmpty(LicenceNameEdit) || string.IsNullOrEmpty(LicenceExpireEdit)) { return; } int index = -1; // check if already exists if so update else add var t = JobDetails.JobLicenses.Where(x => x.Value.ToLower().Trim() == LicenceNameEdit.ToLower().Trim()).FirstOrDefault(); if (t != null) { index = JobDetails.JobLicenses.IndexOf(t); JobDetails.JobLicenses.Remove(t); } // new so just add JobDetailLicenses lnew = new JobDetailLicenses { Value = LicenceNameEdit, ExpiryValue = LicenceExpireEdit }; if (index > -1) { JobDetails.JobLicenses.Insert(index, lnew); } else { JobDetails.JobLicenses.Add(lnew); } ClearLicenceEdit(); }
void RemoveLicence() { if (string.IsNullOrEmpty(LicenceNameEdit)) { return; } // check if already exists if so update else add var t = JobDetails.JobLicenses.Where(x => x.Value.ToLower().Trim() == LicenceNameEdit.ToLower().Trim()).FirstOrDefault(); if (t != null) { JobDetails.JobLicenses.Remove(t); } ClearLicenceEdit(); }