public async Task <IActionResult> Edit(int id, [Bind("Id,Brand,Model,Price,Length,LongDescription,RidingStyle,ImageThumbnailUrl")] Snowboard snowboard)
        {
            if (id != snowboard.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(snowboard);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SnowboardExists(snowboard.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(snowboard));
        }
        public void Details_Passes_Course_To_View()
        {
            var expectedSnowboard = new Snowboard();

            snowboardRepo.GetById(1).Returns(expectedSnowboard);

            var result = underTest.Details(1);

            Assert.Equal(expectedSnowboard, result.Model);
        }
        public async Task <IActionResult> Create([Bind("Id,Brand,Model,Price,Length,LongDescription,RidingStyle,ImageThumbnailUrl")] Snowboard snowboard)
        {
            if (ModelState.IsValid)
            {
                _context.Add(snowboard);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(snowboard));
        }
Beispiel #4
0
    // Use this for initialization
    void Start()
    {
        speeding    = false;
        slowingDown = false;

        //maxSpeed = 4.0f;
        camOriginal = cam.transform.position;
        sb          = GameObject.FindGameObjectWithTag("Snowboard").GetComponent <Snowboard>();

        speed = sb.maxSpeed;

        player = GameObject.FindGameObjectWithTag("Player");
    }
Beispiel #5
0
        public static void AddSnowboard()
        {
            var       _context   = new SnowboardAppContext();
            Snowboard snowboard1 = new Snowboard

            {
                Brand     = "Rome",
                Name      = "Ståle pro",
                Length    = 155,
                AthelteId = 12,
            };

            _context.Snowboards.Add(snowboard1);
            _context.SaveChanges();
        }
        private static void AddSnowboardsToAthelte()
        {
            var context   = new SnowboardAppContext();
            var snowboard = new Snowboard {
                Brand = "Rome", Length = 150, Name = "SKS", AthelteId = 14
            };

            context.Add(snowboard);
            context.SaveChanges();

            var snowboard1 = new Snowboard {
                Brand = "Brädan1337", Length = 1337, Name = "ELIT", AthelteId = 14
            };

            context.Add(snowboard1);
            context.SaveChanges();
        }
        /// <summary>
        /// Creates a snowboard and adds it to the database
        /// </summary>
        /// <param name="name">Snowboard name</param>
        /// <param name="imagePath">Snowboard image path</param>
        /// <param name="price">Snowboard price</param>
        /// <param name="size">Snowboard size in cm</param>
        /// <param name="description">Snowboard description</param>
        /// <param name="brandId">Snowboard brand id</param>
        /// <param name="profile">Snowboard profile</param>
        /// <param name="flex">Snowboard flex rating</param>
        /// <returns>Snowboard id</returns>
        public int CreateSnowboard(string name, string imagePath, decimal price, float size, string description, int brandId, Profile profile, byte flex)
        {
            var snowboard = new Snowboard()
            {
                Name        = name,
                ImagePath   = imagePath,
                Price       = price,
                Size        = size,
                Description = description,
                BrandId     = brandId,
                Profile     = profile,
                Flex        = flex
            };

            context.Snowboards.Add(snowboard);
            context.SaveChanges();

            return(snowboard.Id);
        }