Beispiel #1
0
        public ActionResult AddVenue(VenuesViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            VenuesViewModel venue = new VenuesViewModel
            {
                Name         = model.Name,
                Street       = model.Street,
                StreetNumber = model.StreetNumber,
                CityID       = model.CityID,
                Phone        = model.Phone,
                VenueTypeID  = model.VenueTypeID
            };


            _venuesRepository.Insert(new Venues {
                Name         = venue.Name,
                Street       = venue.Street,
                StreetNumber = venue.StreetNumber,
                CityID       = venue.CityID,
                Phone        = venue.Phone,
                VenueTypeID  = venue.VenueTypeID
            });

            return(RedirectToAction("Index", "Admin"));
        }
Beispiel #2
0
        public VenuesViewModel GetVenues()
        {
            VenuesViewModel venues = new VenuesViewModel();

            venues.Venues = new List <VenueViewModel>();
            var currentUserId = this.User.FindFirst(ClaimTypes.NameIdentifier).Value;
            var currentUser   = _dbContext.Users.SingleOrDefault(x => x.Id == currentUserId);

            if (currentUser != null)
            {
                var company = _dbContext.Company.SingleOrDefault(x => x.CompanyId == currentUser.CompanyId);
                if (company != null)
                {
                    venues.Venues = _dbContext.Venue.Where(x => x.CompanyId == company.CompanyId).Select(x => new VenueViewModel()
                    {
                        Capacity       = x.Capacity,
                        Id             = x.VenueId,
                        Location       = x.VenueLocation,
                        Name           = x.VenueName,
                        NumberOfEvents = _dbContext.Event.Where(e => e.VenueId == x.VenueId).Count()
                    }).ToList();
                }
            }
            return(venues); // will return an empty venue list if can't find user/ company.
        }
Beispiel #3
0
        public async Task <ActionResult> Venues()
        {
            var ViewModel = new VenuesViewModel();

            ViewModel.Venues = await _context.ApplicationUsers
                               .Where(user => user.UserType == "venue")
                               .OrderByDescending(user => user.State)
                               .ToListAsync();

            return(View(ViewModel));
        }
        public async Task <VenuesViewModel> GetVenues(string place, string lat = null, string lng = null)
        {
            var _client = new HttpClient();

            _client.BaseAddress = new Uri(BaseUrl);
            _client.DefaultRequestHeaders.Clear();
            _client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            var api = !string.IsNullOrEmpty(place) ? string.Format("api/landmark/getbyplace/{0}", place) : string.Format("api/landmark/getbyplace/{0}/{1}", lat, lng);

            var httpResponse = await _client.GetAsync(api);

            if (!httpResponse.IsSuccessStatusCode)
            {
                throw new Exception("Cannot retrieve landmarks");
            }
            var content = await httpResponse.Content.ReadAsStringAsync();

            var tasks = JsonConvert.DeserializeObject <Landmarks>(content);
            List <SelectListItem> venueslist = new List <SelectListItem>();

            venueslist.Add(new SelectListItem {
                Text = "Select Venue", Value = string.Empty
            });
            List <VenueModel> vm = new List <VenueModel>();

            foreach (var x in tasks.response.groups[0].items)
            {
                var venueexist = _context.Venues.FirstOrDefault(p => p.id.Equals(x.venue.id));
                if (venueexist == null)
                {
                    vm.Add(new VenueModel {
                        id = x.venue.id, name = x.venue.name
                    });
                }
                venueslist.Add(new SelectListItem()
                {
                    Text  = x.venue.name,
                    Value = x.venue.id
                });
            }
            ViewBag.Venues = venueslist;
            var model = new VenuesViewModel()
            {
                listItems     = venueslist,
                SelectedValue = 1
            };

            //Insert into DB
            _context.Venues.AddRange(vm);
            _context.SaveChanges();

            return(model);
        }
        public async Task <IActionResult> Venues()
        {
            ViewData["Title"] = localizer["Venues"];

            var model = new VenuesViewModel
            {
                Venues = await venuesService.GetVenues(),
                Cities = await citiesService.GetCities()
            };

            return(View("Venues", model));
        }
        public IActionResult Index()
        {
            VenuesViewModel indexViewModel = new VenuesViewModel();

            indexViewModel.listItems = new List <SelectListItem>
            {
                new SelectListItem {
                    Text = "Select Venue", Value = string.Empty
                }
            };
            return(View(indexViewModel));
        }
        //GET: venues/details/id
        public ActionResult Details(int id)
        {
            VenuesViewModel model;
            Venues          venue = _venuesRepository.GetVenueById(id);

            if (venue == null)
            {
                return(Content("This Venue does not exist"));
            }
            model = new VenuesViewModel(venue);


            return(View(model));
        }
        public async Task <IActionResult> Index(int cityId = 1)
        {
            ViewBag.cityId     = cityId;
            ViewBag.cityName   = (await citiesService.GetCityById(cityId))?.Name;
            ViewBag.cityStatus = (await citiesService.GetCityById(cityId))?.Status;

            var model = new VenuesViewModel
            {
                Cities = await citiesService.GetCityesByStatus(CityStatuses.Avaliable, CityStatuses.NotAvaliable),
                Venues = await venuesService.GetVenuesByStatuses(VenueStatuses.Avaliable, VenueStatuses.NotAvaliable)
            };

            return(View(model));
        }
Beispiel #9
0
        public async Task <IActionResult> BookVenuePost([Bind("EventId,VenueCode,VenueName")] VenuesViewModel postVenue)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var @event = await _dataAccess.GetEvents().FirstOrDefaultAsync(e => e.Id == postVenue.EventId);

                    if (@event == null)
                    {
                        return(NotFound());
                    }

                    if (@event.ReservationRef != null)
                    {
                        var r = await _venuesClient.DeleteReservation(@event);
                    }

                    ReservationPostDto postReservation = new ReservationPostDto
                    {
                        VenueCode = postVenue.VenueCode,
                        StaffId   = "s",
                        EventDate = @event.Date,
                    };
                    var reserveVenue = await _venuesClient.AddReservation(postReservation);

                    @event.ReservationRef = reserveVenue.Reference;
                    @event.VenueName      = postVenue.VenueName;

                    _context.Update(@event);
                    await _context.SaveChangesAsync();
                }
                catch
                {
                    if (!EventExists(postVenue.EventId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }

                return(RedirectToAction(nameof(Index)));
            }

            return(View(postVenue));
        }
Beispiel #10
0
        public async Task <IActionResult> BookVenuePost([FromQuery] int eventId, [FromQuery] string venueCode, [FromQuery] string venueName)
        {
            Event @event = await _dataAccess.GetEvents().FirstOrDefaultAsync(e => e.Id == eventId);

            if (@event == null)
            {
                return(NotFound());
            }

            VenuesViewModel postBook = new VenuesViewModel
            {
                EventId    = eventId,
                EventTitle = @event.Title,
                VenueCode  = venueCode,
                VenueName  = venueName
            };

            return(View(postBook));
        }
        public ActionResult UpdateVenue(VenuesViewModel model)
        {
            Venues venue = _venuesRepository.GetVenueById(model.VenueID);

            if (venue == null)
            {
                return(Json(new { success = false, message = "Локалот не постои" }));
            }
            venue.Name         = model.Name;
            venue.Street       = model.Street;
            venue.StreetNumber = model.StreetNumber;
            venue.CityID       = model.CityID;
            venue.Phone        = model.Phone;
            venue.VenueTypeID  = model.VenueTypeID;

            _venuesRepository.Update(venue);
            return(RedirectToAction("Index"));
            //return Json(new { success = true, message = "Success" });
        }
Beispiel #12
0
        // GET: Events/Book
        public async Task <IActionResult> Book(int id)
        {
            var @event = await _dataAccess.GetEvents().FirstOrDefaultAsync(e => e.Id == id);

            if (@event == null)
            {
                return(NotFound());
            }

            var avails = _venuesClient.GetAvailablities(@event);

            var bookingViewModel = new VenuesViewModel
            {
                EventId         = @event.Id,
                AvailableVenues = avails,
                VenueName       = @event.VenueName
            };

            return(View(bookingViewModel));
        }
        public JsonResult DetailsInfo(int id)
        {
            var venue = _venuesRepository.GetVenueById(id);

            if (venue == null)
            {
                return(null);
            }
            VenuesViewModel model = new VenuesViewModel();

            model.VenueID      = venue.VenueID;
            model.Name         = venue.Name;
            model.Street       = venue.Street;
            model.StreetNumber = venue.StreetNumber;
            model.CityID       = venue.CityID;
            model.Phone        = venue.Phone;
            model.VenueTypeID  = venue.VenueTypeID;

            return(Json(model, JsonRequestBehavior.AllowGet));
        }