public bool PutContact(contact_info contact_info) { try { if (ValidatorContact.IsContactExist(contact_info, GetAllContact()) && ValidatorContact.IsValide(contact_info)) { db.Entry(contact_info).State = EntityState.Modified; db.Set <contact_info>().AddOrUpdate(contact_info); db.SaveChanges(); return(true); } else if (!ValidatorContact.IsContactExist(contact_info, GetAllContact())) { throw new ItemNotExistException("contact"); } else { throw new InvalidItemException("contact"); } } catch (Exception e) { throw e; } }
public bool PutProgrammation(programmation programmation) { try { db.Entry(programmation).State = EntityState.Modified; db.SaveChanges(); return(true); } catch (Exception e) { throw e; } }
public bool PutSalle(salle salle) { try { var salles = GetAllSalleFromCinema(salle.cinema_id); var state = db.Entry(salle).State; if (salle.commentaire == null) { salle.commentaire = ""; } if (ValidatorSalle.IsSalleExist(salle, salles) && ValidatorSalle.IsValide(salle) && !ValidatorSalle.IsSalleContainSeance(salle) && !ValidatorSalle.IsSalleConflict(salle, GetAllSalleFromCinema(salle.cinema_id))) { db.Set <salle>().AddOrUpdate(salle); //db.Entry(salle).State = EntityState.Modified; db.SaveChanges(); return(true); } else if (ValidatorSalle.IsSalleContainSeance(salle)) { throw new SalleHaveSeanceException(); } else if (!ValidatorSalle.IsSalleExist(salle, GetAllSalleFromCinema(salle.cinema_id))) { throw new ItemNotExistException("salle"); } else { throw new InvalidItemException("salle"); } } catch (Exception e) { throw e; } }
public bool PutParticipant(participant participant) { try { if (ValidatorParticipant.IsParticipantExist(participant, GetAllParticipant()) && ValidatorParticipant.IsValide(participant)) { db.Entry(participant).State = EntityState.Modified; db.SaveChanges(); return(true); } else if (!ValidatorParticipant.IsParticipantExist(participant, GetAllParticipant())) { throw new ItemNotExistException("participant"); } else { throw new InvalidItemException("participant"); } } catch (Exception e) { throw e; } }
public bool PutUserType(user_type user_type) { try { if (ValidatorUserType.IsUSerTypeExist(user_type, GetAllUserType())) { db.Entry(user_type).State = EntityState.Modified; db.SaveChanges(); return(true); } else if (!ValidatorUserType.IsUSerTypeExist(user_type, GetAllUserType())) { throw new ItemNotExistException("user_type"); } else { throw new InvalidItemException("user_type"); } } catch (Exception e) { throw e; } }
public bool PutGenre(genre genre) { try { if (ValidatorGenre.IsGenreExist(genre, GetAllGenre()) && ValidatorGenre.IsValide(genre)) { db.Entry(genre).State = EntityState.Modified; db.SaveChanges(); return(true); } else if (!ValidatorGenre.IsGenreExist(genre, GetAllGenre())) { throw new ItemNotExistException("genre"); } else { throw new InvalidItemException("genre"); } } catch (Exception e) { throw e; } }
public bool PutUser(user user) { try { if (ValidatorUser.IsUserExist(user, GetAllUser()) && ValidatorUser.IsValide(user)) { db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return(true); } else if (!ValidatorUser.IsUserExist(user, GetAllUser())) { throw new ItemNotExistException("user"); } else { throw new InvalidItemException("user"); } } catch (Exception e) { throw e; } }