public ActionResult Detail(int?id) { //Bool variable for the View: checking if user is venue owner or not ViewBag.IsOwner = false; //Get the current logged in user - will be implemented in the future when the log in function/ page is complete string ownerEmail = User.Identity.GetUserName(); //Check if current logged in user is the owner if (_venueOwnerService.IsVenueOwner(ownerEmail)) { ViewBag.IsOwner = true; VenueOwner owner = _venueOwnerService.GetVenueOwnerByEmail(ownerEmail); //Create the view model using values of the owner if not null CreateVenueOwnerViewModel model = new CreateVenueOwnerViewModel() { VenueOwnerId = owner.VenueOwnerId, FirstName = owner.FirstName, LastName = owner.LastName, Email = owner.Email, PhoneNumber = owner.Phone, CompanyName = owner.CompanyName, SignUpDate = owner.SignUpDate, VenueName = _venueService.GetVenueNameById(owner.VenueId), VenueId = owner.VenueId }; //Return it back to the view return(View(model)); } else { ViewBag.IsOwner = false; VenueOwner owner = _venueOwnerService.GetVenueOwnerById((int)id); CreateVenueOwnerViewModel model = new CreateVenueOwnerViewModel() { VenueOwnerId = owner.VenueOwnerId, FirstName = owner.FirstName, LastName = owner.LastName, Email = owner.Email, PhoneNumber = owner.Phone, CompanyName = owner.CompanyName, SignUpDate = owner.SignUpDate, VenueName = _venueService.GetVenueNameById(owner.VenueId), VenueId = owner.VenueId }; return(View(model)); } }
/* * User's internal profile that only they have access to */ public ActionResult Details() { string userEmail = User.Identity.GetUserName(); // First check if venue owner and route to correct profile if so bool isVenueOwner = _venueOwnerService.IsVenueOwner(userEmail); if (isVenueOwner) { var owner = _venueOwnerService.GetVenueOwnerByEmail(userEmail); return(RedirectToAction("Detail", "VenueOwner", new { id = owner.VenueOwnerId })); } Contact contact = _contactService.GetContactByEmail(userEmail); return(View(contact)); }
public ActionResult GameDetails(int id) { //validating the id to make sure its not null if (id == 0) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ViewGameViewModel model = new ViewGameViewModel(); //getting current logged in user information in case they want to join game string email = User.Identity.GetUserName(); Contact contact = _contactService.GetContactByEmail(email); Game game = _gameService.GetGameById(id); if (contact == null) { // Check if is venue owner. If not, they did not initalize their profile VenueOwner venueOwner = _venueOwnerService.GetVenueOwnerByEmail(email); model.IsCreatorOfGame = false; if (venueOwner.VenueId == game.VenueId) { model.IsVenueOwner = true; } } else if (_gameService.IsCreatorOfGame(contact.ContactId, game)) { model.IsCreatorOfGame = true; model.IsVenueOwner = false; } else { // Check if logged in user is already a part of this game var allPickUpGames = _gameService.GetPickUpGamesByContactId(contact.ContactId); if (allPickUpGames != null) { var existingPickUpGame = allPickUpGames.FirstOrDefault(x => x.GameId == id); if (existingPickUpGame == null) { model.IsAlreadyJoined = false; } else { model.IsAlreadyJoined = true; } } else { model.IsAlreadyJoined = false; } } model.EndDate = game.EndTime.ToString(); model.GameId = game.GameId; model.Status = Enum.GetName(typeof(GameStatusEnum), game.GameStatusId); model.Sport = _gameService.GetSportNameById(game.SportId); model.StartDate = game.StartTime.ToString(); model.Venue = _venueService.GetVenueNameById(game.VenueId); if (game.ContactId != null) { model.ContactId = game.ContactId; model.ContactName = _contactService.GetContactById(game.ContactId).Username; } //returning model to the view return(View(model)); }