public async Task <XPayContactInformation> Edit(XPayContactInformation updatedData) { return(await Task.Run(async() => { try { contactInformation = await Reader <XPayContactInformation> .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 <XPayContactInformation> .JsonWriterListAsync(contactInformation, Model1FileName); return old; } catch (Exception ex) { throw ex; } })); }
public AdminContactInformationController() { Model1 = new XPayContactInformation().GetType().Name; Model1FileName = AppDataFolder + "InnerAPI\\" + Model1 + ".json"; FileChecker <XPayContactInformation> .AutoCreateIfNotExists(Model1FileName); }