private static bool insertUser(EasyRepo.Repo <Users> repoUsers, Users u) { try { repoUsers.Insert(u); return(true); } catch (Exception e) { Console.WriteLine("Inserimento fallito: {0}", e); return(false); } }
private static bool deleteUser(EasyRepo.Repo <Users> repoUsers, Users u) { try { repoUsers.Delete(u); return(true); } catch (Exception e) { Console.WriteLine("Cancellazione fallita: {0}", e); return(false); } }
private static bool updateUser(EasyRepo.Repo <Users> repoUsers, Users u) { try { u.Discriminator = "Modified"; repoUsers.Update(u); return(true); } catch (Exception e) { Console.WriteLine("Modifica fallita: {0}", e); return(false); } }
static void Main(string[] args) { Console.WriteLine("INIZIO TEST with autoCommit {0}", DateTime.Now); var db = new AspNetMyIdentityTestEntities(); EasyRepo.Repo <Users> repoUsers = new EasyRepo.Repo <Users>(db); repoUsers.OnInsertingEventHandler += repoUsers_OnInsertingEventHandler; repoUsers.OnInsertedEventHandler += repoUsers_OnInsertedEventHandler; repoUsers.OnUpdatingEventHandler += repoUsers_OnUpdatingEventHandler; repoUsers.OnUpdatedEventHandler += repoUsers_OnUpdatedEventHandler; repoUsers.OnDeletingEventHandler += repoUsers_OnDeletingEventHandler; repoUsers.OnDeletedEventHandler += repoUsers_OnDeletedEventHandler; UserFilter f = new UserFilter(); var itemsFounded = repoUsers.Find((i) => { return((string.IsNullOrEmpty(f.Nominativo) ? true : i.Nominativo.Contains(f.Nominativo)) && (string.IsNullOrEmpty(f.Id) ? true : i.Id.Equals(f.Id))); }); foreach (var item in itemsFounded) { Console.WriteLine("{0}", item); } Users u = new Users() { Firstname = "Cristopher", Surname = "Fasolin", Mail = "*****@*****.**", Id = Guid.NewGuid().ToString(), Discriminator = "", }; repoUsers.Insert(u); //if (insertUser(repoUsers, u)) // if (updateUser(repoUsers, u)) //deleteUser(repoUsers, u); Console.Read(); }