public ActionResult RateUser(int?id)
        {
            User_Show      show      = db.User_Show.Where(s => s.ShowID == id).FirstOrDefault();
            ShowsViewModel viewModel = new ShowsViewModel(show);

            return(View(viewModel));
        }
        public ActionResult RateUser(int?id, ShowsViewModel model)
        {
            User_Show      show      = db.User_Show.Where(s => s.ShowID == id).FirstOrDefault();
            ShowsViewModel viewModel = new ShowsViewModel(show);
            // Converting string into int
            int    numStars = getRating(model.RatingValue);
            string comment  = model.Comment;

            Models.Rating userRating = new Models.Rating();

            if (User.IsInRole("VenueOwner"))
            {
                User user = db.Users.Where(u => u.ID == viewModel.MusicianID).FirstOrDefault();
                userRating.UserID  = viewModel.MusicianID;
                userRating.Value   = numStars;
                userRating.Comment = comment;
                show.VenueRated    = true;
                user.AveRating     = CalcAveRating(user.ID, numStars);
            }
            else if (User.IsInRole("Musician"))
            {
                User user = db.Users.Where(u => u.ID == viewModel.VenueID).FirstOrDefault();
                userRating.UserID  = viewModel.VenueID;
                userRating.Value   = numStars;
                userRating.Comment = comment;
                show.MusicianRated = true;
                user.AveRating     = CalcAveRating(user.ID, numStars);
            }

            db.Ratings.Add(userRating);
            db.SaveChanges();

            return(RedirectToAction("MyShows"));
        }
Пример #3
0
 public ShowsWindow(ShowsViewModel viewModel)
 {
     InitializeComponent();
     _viewModel = viewModel;
     _viewModel.GenerateTable = GenerateTable;
     _viewModel.Close         = Close;
     gridMain.DataContext     = _viewModel;
 }
Пример #4
0
        public async Task <IActionResult> Index()
        {
            var model = new ShowsViewModel()
            {
                TopRatedShows  = await this.Service.GetTopRatedShows(),
                NowAiringShows = await this.Service.GetNowAiring(),
                genres         = await this.Service.GetGenres()
            };

            return(View(model));
        }
        // GET: Shows/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Show show = db.Shows.Find(id);

            if (show == null)
            {
                return(HttpNotFound());
            }
            User_Show      user_Show = db.User_Show.Where(u => u.ShowID == id).First();
            ShowsViewModel viewModel = new ShowsViewModel(user_Show);

            viewModel.VenueList = new SelectList(db.Venues.Where(s => s.UserID == show.Venue.UserID), "ID", "VenueName");
            return(View(viewModel));
        }
        public async Task <ActionResult> Edit(int?id, ShowsViewModel viewModel)
        {
            // No user id passed through
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Show show = db.Shows.Find(id);

            // If users doesn't exisit
            if (show == null)
            {
                return(HttpNotFound());
            }

            // Viewmodel for Show
            ShowsViewModel model = new ShowsViewModel(show);

            var IdentityID = User.Identity.GetUserId();

            model.VenueList = new SelectList(db.Venues.Where(s => s.UserID == show.Venue.UserID), "ID", "VenueName");

            if (ModelState.IsValid)
            {
                // Get user's calendar credentials
                UserCredential credential = await GetCredentialForApiAsync();

                // Create Google Calendar API service.
                var service = new CalendarService(new BaseClientService.Initializer()
                {
                    HttpClientInitializer = credential,
                    ApplicationName       = "Harmony",
                });

                // Fetch the list of calendars.
                var calendars = await service.CalendarList.List().ExecuteAsync();

                // create a new event to google calendar
                if (calendars != null)
                {
                    Event updatedEvent = new Event()
                    {
                        Summary     = viewModel.Title,
                        Description = viewModel.Description,
                        Location    = db.Venues.Find(viewModel.VenueID).VenueName,
                        Start       = new EventDateTime()
                        {
                            DateTime = viewModel.StartTime.AddHours(7.0),
                            TimeZone = "America/Los_Angeles"
                        },
                        End = new EventDateTime()
                        {
                            DateTime = viewModel.EndTime.AddHours(7.0),
                            TimeZone = "America/Los_Angeles"
                        },
                        Attendees = new List <EventAttendee>()
                        {
                            new EventAttendee()
                            {
                                Email = db.Users.Where(u => u.ID == model.MusicianID).FirstOrDefault().Email
                            },
                            new EventAttendee()
                            {
                                Email = show.Venue.User.Email
                            }
                        }
                    };
                    var newEventRequest = service.Events.Update(updatedEvent, "primary", show.GoogleEventID);
                    // This allows attendees to get email notification
                    newEventRequest.SendNotifications = true;
                    newEventRequest.SendUpdates       = 0;
                    var eventResult = newEventRequest.Execute();

                    // change the show details
                    show.Title         = viewModel.Title;
                    show.StartDateTime = viewModel.StartTime;
                    show.EndDateTime   = viewModel.EndTime;
                    show.Description   = viewModel.Description;
                    show.VenueID       = viewModel.VenueID;
                    db.SaveChanges();

                    return(RedirectToAction("Details", new { id = model.ShowID }));
                }
            }
            return(View(model));
        }
Пример #7
0
 public ShowsPage()
 {
     InitializeComponent();
     BindingContext = _viewModel = new ShowsViewModel();
 }