Пример #1
0
        public ActionResult CopyEvent(int id = 0)
        {
            Event xEvent = db.Events.Single(e => e.Event_Id == id);

            Event newEvent = new Event();

            newEvent.Event_BandId = xEvent.Event_BandId;
            newEvent.Event_Date = xEvent.Event_Date;
            newEvent.Event_Description = xEvent.Event_Description;
            newEvent.Event_EndTime = xEvent.Event_EndTime;
            newEvent.Event_GenreId = xEvent.Event_GenreId;
            newEvent.Event_Name = xEvent.Event_Name;
            newEvent.Event_Photo = xEvent.Event_Photo;
            newEvent.Event_PhotoFileName = xEvent.Event_PhotoFileName;
            newEvent.Event_PhotoMimeType = xEvent.Event_PhotoMimeType;
            newEvent.Event_StartTime = xEvent.Event_StartTime;
            newEvent.Event_VenueId = xEvent.Event_VenueId;

            ViewBag.oldEventId = id;
            ViewBag.VenueName = xEvent.Venue.Venue_Name;

            ViewBag.Event_BandId = new SelectList(db.Bands.OrderBy(b => b.Band_Name), "Band_Id", "Band_Name", newEvent.Event_BandId);
            ViewBag.Event_GenreId = new SelectList(db.Genres.OrderBy(g => g.Genre_Name), "Genre_Id", "Genre_Name", newEvent.Event_GenreId);

            return PartialView(newEvent);
        }
Пример #2
0
        public ActionResult EditEvent(Event Xevent, string VenueName)
        {
            if (ModelState.IsValid)
            {

                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.Entry(Xevent).State = EntityState.Modified;
                db.SaveChanges();

                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);

                return PartialView("DetailsEvent", Xevent);
            }
            else
            {
                return Content("Please review your form");
            }
        }
Пример #3
0
        public ActionResult CreateEvent(Event eventX, string Event_VenueName)
        {
            if (ModelState.IsValid)
            {

                Venue venue = db.Venues.FirstOrDefault(v => v.Venue_Name.Equals(Event_VenueName));
                if (venue != null)
                {
                    //attach the venue
                    eventX.Event_VenueId = venue.Venue_Id;
                }
                else
                {
                    //create a new venue
                    Venue newVenue = new Venue();

                    // remove any unnecessary spaces
                    Event_VenueName.Replace("  ", " ").Trim();
                    newVenue.Venue_Name = Event_VenueName;

                    db.Venues.Add(newVenue);
                    eventX.Event_VenueId = newVenue.Venue_Id;

                }

                // set the creation details
                eventX.Event_CreatedBy = (int)Session["UserID"];
                eventX.Event_CreatedDate = DateTime.Now;

                db.Events.Add(eventX);
                db.SaveChanges();

                // data for the performances
                ViewBag.performances = db.Performances
                    .Where(p => p.Performance_EventId == eventX.Event_Id)
                    .OrderBy(p => p.Performance_Order)
                    .Take(PageSize+1);

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

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

                // data for the MyStatus dropdown
                if (eventX.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);
                }

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

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

                return View("Details", eventX);
            }
            else
            {
                return Content("Please review your form");
            }
        }
Пример #4
0
 public ActionResult Edit(Event eventX)
 {
     if (ModelState.IsValid)
     {
         db.Entry(eventX).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.Event_BandId = new SelectList(db.Bands.OrderBy(b => b.Band_Name), "Band_Id", "Band_Name", eventX.Event_BandId);
     ViewBag.Event_GenreId = new SelectList(db.Genres.OrderBy(g => g.Genre_Name), "Genre_Id", "Genre_Name", eventX.Event_GenreId);
     ViewBag.Event_VenueId = new SelectList(db.Venues.OrderBy(v => v.Venue_Name), "Venue_Id", "Venue_Name", eventX.Event_VenueId);
     return View(eventX);
 }
Пример #5
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");
            }
        }