Ejemplo n.º 1
0
        public async Task <ActionResult> Create(CreateAndEditViewModel createInfo)
        {
            try
            {
                string userId = User.Identity.GetUserId();
                createInfo.Band.ApplicationId = userId;
                int nextLocationId = context.Database.ExecuteSqlCommand("SELECT IDENT_CURRENT('dbo.Locations')") + 1;
                int nextSocialId   = context.Database.ExecuteSqlCommand("SELECT IDENT_CURRENT('dbo.Socials')") + 1;
                createInfo.Band.LocationId = nextLocationId;
                createInfo.Band.socialId   = nextSocialId;

                context.Socials.Add(createInfo.Social);

                context.Bands.Add(createInfo.Band);

                string[] latLng = await GeoCode.GetLatLongFromApi(createInfo.Location);

                createInfo.Location.lat = latLng[0];
                createInfo.Location.lng = latLng[1];

                context.Locations.Add(createInfo.Location);

                await context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(View());
            }
        }
Ejemplo n.º 2
0
        // GET: Band/Edit/5
        public ActionResult Edit()
        {
            CreateAndEditViewModel toEdit = new CreateAndEditViewModel();

            toEdit.Band     = GetUserBand();
            toEdit.Location = GetBandLocation(toEdit.Band);
            toEdit.Social   = GetBandSocials(toEdit.Band);
            return(View(toEdit));
        }
Ejemplo n.º 3
0
        // GET: Venue/Edit/5
        public ActionResult Edit()
        {
            CreateAndEditViewModel toEdit = new CreateAndEditViewModel();

            toEdit.Venue    = GetUserVenue();
            toEdit.Location = GetVenueLocation(toEdit.Venue);

            return(View(toEdit));
        }
Ejemplo n.º 4
0
        // GET: Venue/Create
        // GET: Band/Create
        public ActionResult Create()
        {
            CreateAndEditViewModel createView = new CreateAndEditViewModel();

            createView.Location = new Location();
            createView.Venue    = new Venue();


            return(View(createView));
        }
Ejemplo n.º 5
0
        // GET: Band/Create
        public ActionResult Create()
        {
            CreateAndEditViewModel createView = new CreateAndEditViewModel();

            Location location = new Location();

            createView.Location = location;
            Band band = new Band();

            createView.Band = band;
            SocialMediaIds social = new SocialMediaIds();

            createView.Social = social;

            return(View(createView));
        }
Ejemplo n.º 6
0
        public async Task <ActionResult> Edit(CreateAndEditViewModel input)
        {
            try
            {
                Band           currentBand     = GetUserBand();
                Location       currentLocation = GetBandLocation(currentBand);
                SocialMediaIds currentSocials  = GetBandSocials(currentBand);

                currentBand.BandId      = input.Band.BandId;
                currentBand.bandName    = input.Band.bandName;
                currentBand.genre       = input.Band.genre;
                currentBand.bandWebsite = input.Band.bandWebsite;

                currentBand.ApplicationId = input.Band.ApplicationId;


                currentLocation.address1 = input.Location.address1;
                currentLocation.address2 = input.Location.address2;
                currentLocation.city     = input.Location.city;
                currentLocation.zip      = input.Location.zip;
                currentLocation.state    = input.Location.state;


                currentSocials.facebookPageId   = input.Social.facebookPageId;
                currentSocials.twitterHandle    = input.Social.twitterHandle;
                currentSocials.youtubeChannelId = input.Social.youtubeChannelId;

                string[] latLng = await GeoCode.GetLatLongFromApi(currentLocation);

                currentLocation.lat = latLng[0];
                currentLocation.lng = latLng[1];

                await context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                return(View());
            }
        }
Ejemplo n.º 7
0
        public async Task <ActionResult> Edit(CreateAndEditViewModel input)
        {
            try
            {
                Venue    currentVenue    = GetUserVenue();
                Location currentLocation = GetVenueLocation(currentVenue);


                currentVenue.venueName   = input.Venue.venueName;
                currentVenue.genre       = input.Venue.genre;
                currentVenue.websiteUrl  = input.Venue.websiteUrl;
                currentVenue.description = input.Venue.description;



                currentLocation.address1 = input.Location.address1;
                currentLocation.address2 = input.Location.address2;
                currentLocation.city     = input.Location.city;
                currentLocation.zip      = input.Location.zip;
                currentLocation.state    = input.Location.state;



                string[] latLng = await GeoCode.GetLatLongFromApi(currentLocation);

                currentLocation.lat = latLng[0];
                currentLocation.lng = latLng[1];

                await context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                return(View());
            }
        }