public string UpdateYear(ArchiveModel gads) { try { if (YearExistsByYear(gads.Id)) { Archive existingYear = _dataContext.Archives.Where(f => f.ID == gads.Id).SingleOrDefault(); existingYear.Year = gads.Year; existingYear.FileName = gads.FileName; _dataContext.SubmitChanges(); return "Dati atjaunoti"; } else return "Šāds gads neeksistē"; } catch { return "Kļūda DB apstrādē"; } }
public string InsertFile(ArchiveModel file) { if (_dataContext.Archives.Where(x => x.FileName == file.FileName && x.Year == file.Year).FirstOrDefault() == null) { try { _dataContext.Archives.InsertOnSubmit(new Archive() { FileName = file.FileName, Year = file.Year }); _dataContext.SubmitChanges(); return "Fails piesaistīts"; } catch { return "Kļūda DB apstrādē"; } } else return "Fails jau ir piesaistīts!"; }