Ejemplo n.º 1
0
        public bool Adjust(Tour tourForm)
        {
            tuber_databaseContext _context    = new tuber_databaseContext();
            List <Session>        newSessions = tourForm.Session.ToList();

            tourForm.Session = null;
            int tourId     = tourForm.TourId;
            int nextSessId = _context.Session.Max(row => row.SessionId);

            _context.Tour.Update(tourForm);
            newSessions.ForEach(sess =>
            {
                if (sess.SessionId == 0)
                {
                    sess.SessionId = ++nextSessId;
                    _context.Session.Add(sess);
                }
                else
                {
                    _context.Session.Update(sess);
                }
            });
            _context.SaveChanges();
            return(true);
        }
Ejemplo n.º 2
0
        public bool Adjust(Tour tourForm)
        {
            tuber_databaseContext _context = new tuber_databaseContext();
            int tourId = tourForm.TourId;

            _context.Tour.Remove(tourForm);
            _context.SaveChanges();
            return(true);
        }
Ejemplo n.º 3
0
        public bool Adjust(Tour tourForm)
        {
            tuber_databaseContext _context = new tuber_databaseContext();
            int nextTourId = _context.Tour.Max(row => row.TourId) + 1;
            int nextSessId = _context.Session.Max(row => row.SessionId);

            foreach (Session sess in tourForm.Session)
            {
                sess.SessionId = ++nextSessId;
            }
            tourForm.TourId = nextTourId;
            _context.Tour.Add(tourForm);
            _context.SaveChanges();
            return(true);
        }