예제 #1
0
        public IActionResult VenueNewCreate(Models.Venue venue)
        {
            if (HttpContext.Session.GetInt32("UserID") == null)
            {
                return(RedirectToAction("Login", "Home"));
            }
            viewBagVenues();

            if (ModelState.IsValid)
            {
                venue.Creator = userInSession;


                double latitude, longitude;
                HelperClass.getLatLong(venue.Address, out latitude, out longitude);
                venue.Latitude  = latitude;
                venue.Longitude = longitude;


                dbContext.Venues.Add(venue);
                dbContext.SaveChanges();
                var venueID = dbContext.Venues.OrderByDescending(w => w.CreatedAt).FirstOrDefault().VenueID;

                return(Redirect($"/Venue/{venueID}"));
            }
            return(View("VenueNew", venue));
        }
예제 #2
0
        // GET: AddVenue
        public ActionResult Index()
        {
            var db     = new CodeFirst.CodeFirst();
            var venues = new Models.Venue();

            venues.Buildings = db.Buildings.ToList();
            return(View(venues));
        }
        private async Task OpenVenueWindow(Models.Venue venue, string title)
        {
            DisplayError(string.Empty);
            var viewModel = await _windowHelper.GetViewModel <VenueViewModel>() as VenueViewModel;

            viewModel.Venue = venue;
            viewModel.Title = title;
            _windowHelper.ShowDialog(viewModel);
        }
예제 #4
0
 // GET: Venues
 public ActionResult Index()
 {
     Models.Venue myModel = new Models.Venue();
     if (TempData["model"] != null)
     {
         myModel = (Models.Venue)TempData["model"];
         TempData.Remove("model");
     }
     return(View(myModel));
 }
예제 #5
0
 public static Venue ToVenueContract(Models.Venue from)
 {
     return(new Venue
     {
         Address = from.Address,
         Description = from.Description,
         Id = from.Id,
         LayoutList = from.LayoutList.Select(x => LayoutParser.ToLayoutContract(x)).ToArray(),
         Name = from.Name,
         Phone = from.Phone,
         Timezone = from.Timezone
     });
 }
예제 #6
0
        public static Services.Models.Venue CreateVenueDataModel(this Models.Venue venue)
        {
            var config = new MapperConfiguration(
                (cfg) =>
            {
                cfg.CreateMap <Models.Venue, Services.Models.Venue>()
                .ForMember(src => src.ShowDateTime, opt => opt.MapFrom(src => DateTime.Parse(src.ShowDateTime)))
                .ForMember(src => src.ShowId, opt => opt.MapFrom(src => int.Parse(src.ShowId)))
                .ForMember(src => src.ShowPrice, opt => opt.MapFrom(src => Decimal.Parse(src.ShowPrice)));
            }
                );

            return(config.CreateMapper().Map <Services.Models.Venue>(venue));
        }
예제 #7
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Venue = await _context.Venues.FirstOrDefaultAsync(m => m.VenueID == id);

            if (Venue == null)
            {
                return(NotFound());
            }
            return(Page());
        }
        private async Task OnEditVenue(object obj)
        {
            if (!(obj is Models.Venue venue))
            {
                return;
            }

            var edit = await _venueService.GetFullModelAsync(venue.Id);

            venue.LayoutList = VenueParser.ToVenue(edit).LayoutList;

            _markedVenue = venue;
            await OpenVenueWindow(venue, string.Format(l10n.VenueView.View.EditTitle, edit.Name));

            _markedVenue = null;
        }
예제 #9
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Venue = await _context.Venues.FindAsync(id);

            if (Venue != null)
            {
                _context.Venues.Remove(Venue);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
예제 #10
0
        // GET: VenueDetails
        public ActionResult Index(string venueID)
        {
            Models.Venue        myModel = new Models.Venue();
            CodeFirst.CodeFirst db      = new CodeFirst.CodeFirst();
            if (venueID != null)
            {
                var intVenueID = Int32.Parse(venueID);
                var myVenue    = db.Venues.Where(i => i.VenueID == intVenueID).FirstOrDefault();
                var myBuilding = db.Buildings.Where(i => i.BuildingID == myVenue.BuildingID).FirstOrDefault();

                myModel.VenueID      = myVenue.VenueID;
                myModel.Name         = myVenue.Name;
                myModel.BuildingID   = myVenue.BuildingID;
                myModel.BuildingName = myBuilding.Name;
            }

            myModel.Buildings = db.Buildings.ToList();
            return(View(myModel));
        }
예제 #11
0
        public ActionResult Modify([Bind(Prefix = "")] Models.Venue model)
        {
            var db = new CodeFirst.CodeFirst();

            if (ModelState.IsValid)
            {
                var venue = db.Venues.Where(v => v.VenueID == model.VenueID).SingleOrDefault();

                if (venue != null)
                {
                    venue.Name       = model.Name;
                    venue.BuildingID = model.BuildingID;
                    db.SaveChanges();
                }

                TempData["js"] = "myUpdateSuccess()";
                return(RedirectToAction("Index", "Venues"));
            }
            model.Buildings = db.Buildings.ToList();
            return(View("Index", model));
        }
예제 #12
0
        public async Task <IHttpActionResult> Get(string venueReference)
        {
            bool converts = int.TryParse(venueReference, out int venueId);

            if (converts == false)
            {
                return(BadRequest());
            }

            DatabaseAccess.ExternalModel.Venue databaseVenue = await _venueRepository.GetVenueAsync(venueId);

            if (databaseVenue == null)
            {
                return(NotFound());
            }

            Models.Venue venue = Models.Venue.Convert(databaseVenue);

            venue.Link = Url.Content("~/") + "venue/" + databaseVenue.VenueId;

            return(Ok(venue));
        }
예제 #13
0
        public ActionResult Create([Bind(Prefix = "")] Models.Venue model)
        {
            var db = new CodeFirst.CodeFirst();

            if (ModelState.IsValid)
            {
                if (db.Venues.Count() > 0)
                {
                    var item = db.Venues.OrderByDescending(a => a.VenueID).FirstOrDefault();

                    db.Venues.Add(new CodeFirst.Venue
                    {
                        VenueID    = item.VenueID + 1,
                        Name       = model.Name,
                        BuildingID = model.BuildingID
                    });
                }
                else
                {
                    db.Venues.Add(new CodeFirst.Venue
                    {
                        VenueID    = 1,
                        Name       = model.Name,
                        BuildingID = model.BuildingID
                    });
                }

                db.SaveChanges();
                model.JavaScriptToRun = "mySuccess()";
                TempData["model"]     = model;
                return(RedirectToAction("Index", "Venues"));
            }

            model.Buildings = db.Buildings.ToList();
            return(View("Index", model));
        }