Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,SiteId,LabourId,Date,InvoiceNo,Supplier,Description,Amount")] MaterialExpense materialExpense)
        {
            if (id != materialExpense.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(materialExpense);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MaterialExpenseExists(materialExpense.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["LabourId"] = new SelectList(_context.labours, "Id", "Name", materialExpense.LabourId);
            ViewData["SiteId"]   = new SelectList(_context.Sites, "Id", "Name", materialExpense.SiteId);
            return(View(materialExpense));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Id,SiteId,LabourId,Date,InvoiceNo,Supplier,Description,Amount")] MaterialExpense materialExpense)
        {
            if (ModelState.IsValid)
            {
                _context.Add(materialExpense);
                await _context.SaveChangesAsync();

                TempData["Success"] = "Success!";
                return(RedirectToAction(nameof(Create)));
            }
            ViewData["LabourId"] = new SelectList(_context.labours, "Id", "Name", materialExpense.LabourId);
            ViewData["SiteId"]   = new SelectList(_context.Sites, "Id", "Name", materialExpense.SiteId);
            return(View(materialExpense));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create(MaterialExpense materialExpense)
        {
            if (ModelState.IsValid)
            {
                _context.Add(materialExpense);
                await _context.SaveChangesAsync();

                TempData["Success"] = "Success!";

                return(RedirectToAction(nameof(Create)));
            }
            // PopulateDepartmentsDropDownList(course.DepartmentID);
            PopulateLabourDropDownList(materialExpense.LabourId);
            PopulateSiteDropDownList(materialExpense.SiteId);

            return(View(materialExpense));
        }