Example #1
0
        public ActionResult NewPerformanceArtist(int PerformanceId)
        {
            Performance performance = db.Performances.Single(p => p.Performance_Id == PerformanceId);

            int GenreId = db.Performances.Single(p => p.Performance_Id == PerformanceId).Event.Event_GenreId;
            int PieceId = db.Performances.Single(p => p.Performance_Id == PerformanceId).Performance_PieceId;

            ViewBag.PerformanceId = PerformanceId;

            ViewBag.PerformanceArtist_RoleId = new SelectList(
                db.Roles
                    .Where(r => r.Role_GenreId == GenreId || r.Role_PieceId == PieceId)
                    .OrderBy(r => r.Role_Rank),

                "Role_Id",
                "Role_Name");

            PerformanceArtist performanceArtist = new PerformanceArtist();
            performanceArtist.PerformanceArtist_PerformanceId = PerformanceId;

            return PartialView("NewPerformanceArtist", performanceArtist);
        }
Example #2
0
        public ActionResult EditPerformanceArtist(PerformanceArtist performanceArtist, string OtherRole, string PerformanceArtist_ArtistFullName)
        {
            if (ModelState.IsValid)
            {

                // Role
                if (OtherRole != null && OtherRole.Length > 0)
                {

                    //Check the Role
                    Role role = db.Roles.FirstOrDefault(r => r.Role_Id == performanceArtist.PerformanceArtist_RoleId);
                    if (role.Role_Name == "Other")
                    {
                        // Create a new Role

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

                        Role newRole = new Role();
                        newRole.Role_Name = OtherRole;

                        Performance performance = db.Performances.FirstOrDefault(p => p.Performance_Id == performanceArtist.PerformanceArtist_PerformanceId);
                        newRole.Role_PieceId = performance.Performance_PieceId;

                        newRole.Role_Rank = db.Roles.Where(r => r.Role_PieceId == performance.Performance_PieceId).Select(r => r.Role_Rank).Max() + 1;

                        db.Roles.Add(newRole);

                        performanceArtist.PerformanceArtist_RoleId = newRole.Role_Id;
                    }
                }

                // Artist
                Artist artist = db.Artists.FirstOrDefault(a => string.Concat(a.Artist_FirstName, " ", a.Artist_LastName).Equals(PerformanceArtist_ArtistFullName));
                if (artist != null)
                {
                    //attach the artist
                    performanceArtist.PerformanceArtist_ArtistId = artist.Artist_Id;
                }
                else
                {
                    //create a new artist

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

                    string firstName = "";
                    string lastName;

                    // find the position of the last space
                    int i = PerformanceArtist_ArtistFullName.LastIndexOf(" ");

                    if (i > 0)
                    {
                        //there are two words or more
                        firstName = PerformanceArtist_ArtistFullName.Substring(0, i).Trim();
                        lastName = PerformanceArtist_ArtistFullName.Substring(i, PerformanceArtist_ArtistFullName.Length - i).Trim();

                    }
                    else
                    { //there's only one word
                        lastName = PerformanceArtist_ArtistFullName;
                    }

                    Artist newArtist = new Artist();
                    newArtist.Artist_FirstName = firstName;
                    newArtist.Artist_LastName = lastName;
                    db.Artists.Add(newArtist);

                    performanceArtist.PerformanceArtist_ArtistId = newArtist.Artist_Id;

                }

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

                ViewBag.artist = db.Artists.Find(performanceArtist.PerformanceArtist_ArtistId);
                ViewBag.role = db.Roles.Find(performanceArtist.PerformanceArtist_RoleId);

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

                return PartialView("DetailsPerformanceArtist", performanceArtist);
            }
            else
            {
                return Content("Please review your form");
            }
        }
Example #3
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");
            }
        }