Example #1
0
 public async Task <ClientsContactInformation> Edit(ClientsContactInformation updatedData)
 {
     return(await Task.Run(async() => {
         try {
             contactInformation = await Reader <ClientsContactInformation> .JsonReaderListAsync(Model1FileName);
             if (contactInformation.Count == 0)
             {
                 throw new Exception("No data to be update");
             }
             var old = contactInformation.Where(a => a.Id.Equals(updatedData.Id)).FirstOrDefault();
             if (old == null)
             {
                 throw new Exception("No data to be update");
             }
             contactInformation = contactInformation.Where(a => !a.Id.Equals(updatedData.Id)).ToList();
             updatedData.DateUpdated = DateTime.Now;
             contactInformation.Add(updatedData);
             _ = await Writer <ClientsContactInformation> .JsonWriterListAsync(contactInformation, Model1FileName);
             return old;
         } catch (Exception ex) {
             throw ex;
         }
     }));
 }
Example #2
0
 public ContactInformationController()
 {
     Model1         = new ClientsContactInformation().GetType().Name;
     Model1FileName = AppDataFolder + "InnerAPI\\" + Model1 + ".json";
     FileChecker <ClientsContactInformation> .AutoCreateIfNotExists(Model1FileName);
 }