Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,CategoryId,DurationId,GeartypeId,Price")] Rentprices rentprices)
        {
            if (id != rentprices.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(rentprices);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RentpricesExists(rentprices.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Code", rentprices.CategoryId);
            ViewData["DurationId"] = new SelectList(_context.Durations, "Id", "Code", rentprices.DurationId);
            ViewData["GeartypeId"] = new SelectList(_context.Geartypes, "Id", "Name", rentprices.GeartypeId);
            return(View(rentprices));
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("Id,CategoryId,DurationId,GeartypeId,Price")] Rentprices rentprices)
        {
            if (ModelState.IsValid)
            {
                _context.Add(rentprices);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Code", rentprices.CategoryId);
            ViewData["DurationId"] = new SelectList(_context.Durations, "Id", "Code", rentprices.DurationId);
            ViewData["GeartypeId"] = new SelectList(_context.Geartypes, "Id", "Name", rentprices.GeartypeId);
            return(View(rentprices));
        }