Exemple #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,ItemId,ContractId,DurationId,CategoryId,Price,Description,Linenb,Partialreturn")] Renteditems renteditems)
        {
            if (id != renteditems.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(renteditems);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RenteditemsExists(renteditems.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Code", renteditems.CategoryId);
            ViewData["ContractId"] = new SelectList(_context.Contracts, "Id", "Id", renteditems.ContractId);
            ViewData["DurationId"] = new SelectList(_context.Durations, "Id", "Code", renteditems.DurationId);
            ViewData["ItemId"]     = new SelectList(_context.Items, "Id", "Itemnb", renteditems.ItemId);
            return(View(renteditems));
        }
Exemple #2
0
        public async Task <IActionResult> Create([Bind("Id,ItemId,ContractId,DurationId,CategoryId,Price,Description,Linenb,Partialreturn")] Renteditems renteditems)
        {
            if (ModelState.IsValid)
            {
                _context.Add(renteditems);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Code", renteditems.CategoryId);
            ViewData["ContractId"] = new SelectList(_context.Contracts, "Id", "Id", renteditems.ContractId);
            ViewData["DurationId"] = new SelectList(_context.Durations, "Id", "Code", renteditems.DurationId);
            ViewData["ItemId"]     = new SelectList(_context.Items, "Id", "Itemnb", renteditems.ItemId);
            return(View(renteditems));
        }