public ActionResult Create(Performance performance)
        {
            if (ModelState.IsValid)
            {
                db.Performances.Add(performance);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.Performance_PieceId = new SelectList(db.Pieces, "Piece_Id", "Piece_Name", performance.Performance_PieceId);
            ViewBag.Performance_ProductionId = new SelectList(db.Productions, "Production_Id", "Production_Name", performance.Performance_ProductionId);
            return View(performance);
        }
Esempio n. 2
0
        public ActionResult EditPerformance(Performance performance, string PieceName)
        {
            if (ModelState.IsValid)
            {
                Piece piece = db.Pieces.FirstOrDefault(a => a.Piece_Name == PieceName);
                if (piece != null)
                {
                    //attach the artist
                    performance.Performance_PieceId = piece.Piece_Id;
                }
                else
                {
                    //create a new piece

                    // remove any unnecessary spaces
                    PieceName.Replace("  ", " ").Trim();

                    Piece newPiece = new Piece();
                    newPiece.Piece_Name = PieceName;
                    db.Pieces.Add(newPiece);

                    performance.Performance_PieceId = newPiece.Piece_Id;
                }

                db.Entry(performance).State = EntityState.Modified;
                db.SaveChanges();

                // Can the current user edit this event?
                ViewBag.UserCanEditEvent = true;

                return PartialView("DetailsPerformance", performance);
            }
            else
            {
                return Content("Please review your form");
            }
        }
Esempio n. 3
0
        public ActionResult NewPerformance(int EventId)
        {
            Event xevent = db.Events.Single(e => e.Event_Id == EventId);
            int GenreId = db.Events.Single(e => e.Event_Id == EventId).Event_GenreId;

            ViewBag.EventId = EventId;

            ViewBag.Performance_PieceId = new SelectList(db.Pieces
                .Where(p => p.Piece_GenreId == GenreId)
                .OrderBy(p => p.Piece_Name), "Piece_Id", "Piece_Name");

            ViewBag.Performance_ProductionId = new SelectList(db.Productions.OrderBy(p => p.Production_Name), "Production_Id", "Production_Name");

            Performance performance = new Performance();
            performance.Performance_EventId = EventId;

            return PartialView("NewPerformance", performance);
        }
Esempio n. 4
0
        public ActionResult CopyEvent(Event xEvent, int oldEventId, string VenueName)
        {
            if (ModelState.IsValid)
            {

                // Sort out the venue
                Venue venue = db.Venues.FirstOrDefault(a => a.Venue_Name == VenueName);
                if (venue != null)
                {
                    //attach the artist
                    xEvent.Event_VenueId = venue.Venue_Id;
                }
                else
                {
                    //create a new piece

                    // remove any unnecessary spaces
                    VenueName.Replace("  ", " ").Trim();

                    Venue newVenue = new Venue();
                    newVenue.Venue_Name = VenueName;
                    db.Venues.Add(newVenue);

                    xEvent.Event_VenueId = newVenue.Venue_Id;
                }

                db.Events.Add(xEvent);
                db.Entry(xEvent).State = EntityState.Added;
                db.SaveChanges();

                // copy over all the child objects
                Event oldEvent = db.Events.Single(e => e.Event_Id == oldEventId);

                foreach (PerfV400.Models.Performance performance in oldEvent.Performances)
                {

                    Performance newPerformance = new Performance();
                    newPerformance.Performance_EventId = xEvent.Event_Id;
                    newPerformance.Performance_Order = performance.Performance_Order;
                    newPerformance.Performance_Photo = performance.Performance_Photo;
                    newPerformance.Performance_PhotoFileName = performance.Performance_PhotoFileName;
                    newPerformance.Performance_PhotoMimeType = performance.Performance_PhotoMimeType;
                    newPerformance.Performance_PieceId = performance.Performance_PieceId;
                    newPerformance.Performance_ProductionId = performance.Performance_ProductionId;

                    db.Performances.Add(newPerformance);
                    db.Entry(newPerformance).State = EntityState.Added;
                    db.SaveChanges();

                    foreach (PerfV400.Models.PerformanceArtist performanceArtist in performance.PerformanceArtists)
                    {

                        PerformanceArtist newPerformanceArtist = new PerformanceArtist();
                        newPerformanceArtist.PerformanceArtist_ArtistId = performanceArtist.PerformanceArtist_ArtistId;
                        newPerformanceArtist.PerformanceArtist_Comments = performanceArtist.PerformanceArtist_Comments;
                        newPerformanceArtist.PerformanceArtist_PerformanceId = newPerformance.Performance_Id;
                        newPerformanceArtist.PerformanceArtist_Photo = performanceArtist.PerformanceArtist_Photo;
                        newPerformanceArtist.PerformanceArtist_RoleId = performanceArtist.PerformanceArtist_RoleId;

                        db.PerformanceArtists.Add(newPerformanceArtist);
                        db.Entry(newPerformanceArtist).State = EntityState.Added;

                    }

                }

                db.SaveChanges();

            // Retrieve the data for the view

                // data for the performances
                ViewBag.performances = db.Performances
                    .Where(p => p.Performance_EventId == xEvent.Event_Id)
                    .OrderBy(p => p.Performance_Order)
                    .Take(60)
                    .Include(p => p.Piece.Genre)
                    .Include(p => p.PerformanceArtists.Select(pa => pa.Role))
                    .Include(p => p.PerformanceArtists.Select(pa => pa.Artist))
                    ;

                // data for the venue
                ViewBag.Venue = db.Venues.FirstOrDefault(v => v.Venue_Id == xEvent.Event_VenueId);

                // data for the genre
                ViewBag.Genre = db.Genres.FirstOrDefault(g => g.Genre_Id == xEvent.Event_GenreId);

                // Can the current user edit this event?
                ViewBag.UserCanEditEvent = true;

                // data for the MyStatus dropdown
                if (xEvent.Event_Date < DateTime.Today)
                {
                    var query = db.EventUserStatus.OrderBy(c => c.EventUserStatus_Id)
                        .Select(c => new
                        {
                            c.EventUserStatus_Id,
                            c.EventUserStatus_Past
                        });

                    ViewBag.MyStatus = new SelectList(query.AsEnumerable(), "EventUserStatus_Id", "EventUserStatus_Past", ViewBag.EventUser_StatusId);
                }
                else
                {
                    var query = db.EventUserStatus.OrderBy(c => c.EventUserStatus_Id)
                        .Select(c => new
                        {
                            c.EventUserStatus_Id,
                            c.EventUserStatus_Future
                        });

                    ViewBag.MyStatus = new SelectList(query.AsEnumerable(), "EventUserStatus_Id", "EventUserStatus_Future", ViewBag.EventUser_StatusId);
                }

                // sort out the paging
                ViewBag.page = 0;
                ViewBag.PageSize = PageSize;

                return PartialView("Details", xEvent);

            }
            else
            {
                return Content("Please review your form");
            }
        }
 public ActionResult Edit(Performance performance)
 {
     if (ModelState.IsValid)
     {
         db.Entry(performance).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.Performance_PieceId = new SelectList(db.Pieces, "Piece_Id", "Piece_Name", performance.Performance_PieceId);
     ViewBag.Performance_ProductionId = new SelectList(db.Productions, "Production_Id", "Production_Name", performance.Performance_ProductionId);
     return View(performance);
 }