예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Quantity,Costs,Date,EmployeeID,ProjectID,MaterialID")] MaterialReport materialReport)
        {
            if (id != materialReport.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(materialReport);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MaterialReportExists(materialReport.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmployeeID"] = new SelectList(_context.Employees, "ID", "Email", materialReport.EmployeeID);
            ViewData["MaterialID"] = new SelectList(_context.Materials, "ID", "Description", materialReport.MaterialID);
            ViewData["ProjectID"]  = new SelectList(_context.Projects, "ID", "Name", materialReport.ProjectID);
            return(View(materialReport));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("ID,Quantity,Costs,Date,EmployeeID,ProjectID,MaterialID")] MaterialReport materialReport)
        {
            if (ModelState.IsValid)
            {
                _context.Add(materialReport);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmployeeID"] = new SelectList(_context.Employees, "ID", "FullName", materialReport.EmployeeID);
            ViewData["MaterialID"] = new SelectList(_context.Materials, "ID", "Description", materialReport.MaterialID);
            ViewData["ProjectID"]  = new SelectList(_context.Projects, "ID", "Name", materialReport.ProjectID);
            return(View(materialReport));
        }