public async Task <IActionResult> Edit(short id, [Bind("AddendumWorkDetailId,Amount,ActualCost,Sign,AddendumId,SchoolId")] AddendumWorkDetail addendumWorkDetail) { if (id != addendumWorkDetail.AddendumWorkDetailId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(addendumWorkDetail); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AddendumWorkDetailExists(addendumWorkDetail.AddendumWorkDetailId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["AddendumId"] = new SelectList(_context.AddendumWorks, "AddendumId", "AddendumId", addendumWorkDetail.AddendumId); ViewData["SchoolId"] = new SelectList(_context.Schools, "SchoolID", "SName", addendumWorkDetail.SchoolId); return(View(addendumWorkDetail)); }
public async Task <IActionResult> Create([Bind("AddendumWorkDetailId,Amount,ActualCost,Sign,AddendumId,SchoolId")] AddendumWorkDetail addendumWorkDetail) { if (ModelState.IsValid) { _context.Add(addendumWorkDetail); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["AddendumId"] = new SelectList(_context.AddendumWorks, "AddendumId", "AddendumId", addendumWorkDetail.AddendumId); ViewData["SchoolId"] = new SelectList(_context.Schools, "SchoolID", "SName", addendumWorkDetail.SchoolId); return(View(addendumWorkDetail)); }
public IActionResult CreateList(short id, short AddendumId) { var SchoolList = _context.WorkSchool.Include(a => a.School).Where(a => a.ActivityDetailWorkID == id).ToList(); List <AddendumWorkDetail> AddWorkDetailObjList = new List <AddendumWorkDetail>(); foreach (var SchoolObj in SchoolList) { AddendumWorkDetail Obj = new AddendumWorkDetail(); Obj.AddendumId = AddendumId; Obj.SchoolId = SchoolObj.SchoolID; Obj.ActualCost = SchoolObj.ActualCost ?? 0; Obj.School = new School(); Obj.School = SchoolObj.School; AddWorkDetailObjList.Add(Obj); } return(View(AddWorkDetailObjList)); }