public async Task <IActionResult> Edit(string id, [Bind("Id,CommercialName,LegalName,Country,Region,City,CreationDate,BusinessId")] LocalBusiness localBusiness)
        {
            if (id != localBusiness.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(localBusiness);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LocalBusinessExists(localBusiness.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(localBusiness));
        }
Ejemplo n.º 2
0
        public void ToStringWithNullAssignedProperty_ReturnsExpectedJsonLd()
        {
            var localBusiness = new LocalBusiness()
            {
                PriceRange = "$$$",
                Address    = null
            };
            var actual   = localBusiness.ToString();
            var expected =
                "{" +
                "\"@context\":\"http://schema.org\"," +
                "\"@type\":\"LocalBusiness\"," +
                "\"priceRange\":\"$$$\"" +
                "}";

            Assert.Equal(expected, actual);
        }
        public async Task <IActionResult> Create([Bind("Id,CommercialName,LegalName,Country,Region,City,CreationDate,BusinessId")] LocalBusiness localBusiness)
        {
            if (ModelState.IsValid)
            {
                //verification of repeated id
                foreach (LocalBusiness l in _context.LocalBusiness)
                {
                    if (l.Id == localBusiness.Id)
                    {
                        //In case of a repeated Id viewbag needs to be reloaded
                        ViewBag.LocalBusinessId = GetBusinessIds();
                        ViewBag.IdAlreadyExists = "ID ya existe, porfavor intente otro ID";
                        return(View());
                    }
                }
                _context.Add(localBusiness);
                await _context.SaveChangesAsync();

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

            return(View(localBusiness));
        }
Ejemplo n.º 4
0
        public void LocalBusinessTest()
        {
            LocalBusiness shop = new LocalBusiness()
            {
                Name               = "1010Tires.com",
                Description        = "Sell Wheels and Tires.",
                CurrenciesAccepted = "USD, CAD",
            };

            Language language = new Language()
            {
                Name = "English, French"
            };                                                               //may need more differentiation

            shop.Address = new PostalAddress()
            {
                AddressCountry    = "CA",
                AddressRegion     = "BC",
                AddressLocality   = "Vancouver",
                PostalCode        = "V5X 2T7",
                StreetAddress     = "732 Southeast Marine Drive",
                AreaServed        = "Vancouver",
                AvailableLanguage = language,
                Email             = "*****@*****.**",
                Telephone         = "604-324-5999",
            };
            shop.Location     = new Place();
            shop.Location.Geo = new GeoCoordinates("49.210978", "-123.089581");

            OpeningHoursSpecification mondayHours = new OpeningHoursSpecification("5:30 PM", DaysOfWeek.Mo, "9:00 AM");

            shop.Location.OpeningHoursSpecification = new List <OpeningHoursSpecification>();
            shop.Location.OpeningHoursSpecification.Add(mondayHours);

            System.Diagnostics.Debug.Write(shop.ToJson());
        }