예제 #1
0
        public Boolean InsertLocation(int id, String user, int duree)
        {
            DateTime DateTime = DateTime.Today;
            var      query    = from f in _context.LocationsFilms where f.idFilm == id select f;
            int      count    = _context.LocationsFilms.Count();
            int      cpt      = 0;

            foreach (LocationsFilm f in query)
            {
                //pas ok car déja en cours de location
                cpt++;
                return(false);
            }
            if (cpt == 0)
            {
                //ok
                LocationsFilm Loc = new LocationsFilm();
                Loc.idLocationsFilm = count + 1;
                Loc.idFilm          = id;
                Loc.Utilisateur     = user;
                Loc.DateDebut       = DateTime;
                Loc.DateFin         = DateTime.AddMonths(duree);
                _context.LocationsFilms.InsertOnSubmit(Loc);
                try
                {
                    _context.SubmitChanges();
                    return(true);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    return(false);
                }
            }
            return(true);
        }
 partial void DeleteLocationsFilm(LocationsFilm instance);
 partial void InsertLocationsFilm(LocationsFilm instance);
 partial void UpdateLocationsFilm(LocationsFilm instance);
 private void detach_LocationsFilms(LocationsFilm entity)
 {
     this.SendPropertyChanging();
     entity.Utilisateur1 = null;
 }