public async Task <IActionResult> Create([Bind("WhardId,WhardInumber,WhardFnumber,WhardWcatId,WhardWtypeId,WhardName" + ",WhardDateOfAdoption,WhardInitialCost,WhardResidualValue,WhardOfficeId" + ",WhardNote,WhardArchiv,WhardCreateDate,WhardMolEmployeeId,WhardRegionId,IsSoftDeployed")] WealthHardware wealthHardware, bool WhardArchiv, bool IsSoftDeployed, string filter = "", int page = 1, string sortExpression = "WhardId") { ViewBag.Filter = filter; ViewBag.Page = page; ViewBag.SortExpression = sortExpression; wealthHardware.WhardArchiv = WhardArchiv ? 1 : 0; wealthHardware.IsSoftDeployed = IsSoftDeployed ? 1 : 0; ModelState.Clear(); if (ModelState.IsValid) { _context.Add(wealthHardware); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index), new { filter = filter, page = page, sortExpression = sortExpression })); } ViewData["WhardMolEmployeeId"] = _ControlesItems.GetMOLEmployeesByRegion(wealthHardware.WhardRegion.RegionId); ViewData["WhardOfficeId"] = _ControlesItems.GetOfficesByRegion(wealthHardware.WhardRegion.RegionId); ViewData["WhardRegionId"] = new SelectList(_context.Region, "RegionId", "RegionName", wealthHardware.WhardRegionId); ViewData["WhardWcatId"] = new SelectList(_context.WealthCategories, "WcatId", "Wcatname", wealthHardware.WhardWcatId); ViewData["WhardWtypeId"] = new SelectList(_context.WealthTypes, "WtypeId", "WtypeName", wealthHardware.WhardWtypeId); return(View(wealthHardware)); }
public async Task <IActionResult> Edit(int id, [Bind("WhardId,WhardInumber,WhardFnumber,WhardWcatId,WhardWtypeId" + ",WhardName,WhardDateOfAdoption,WhardInitialCost,WhardResidualValue,WhardOfficeId,WhardNote" + ",WhardArchiv,WhardCreateDate,WhardMolEmployeeId,WhardRegionId,IsSoftDeployed")] WealthHardware wealthHardware, bool WhardArchiv, bool IsSoftDeployed, string filter = "", int page = 1, string sortExpression = "WhardId") { ViewBag.Filter = filter; ViewBag.Page = page; ViewBag.SortExpression = sortExpression; wealthHardware.WhardArchiv = WhardArchiv ? 1 : 0; wealthHardware.IsSoftDeployed = IsSoftDeployed ? 1 : 0; ModelState.Clear(); if (id != wealthHardware.WhardId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(wealthHardware); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!WealthHardwareExists(wealthHardware.WhardId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index), new { filter = filter, page = page, sortExpression = sortExpression })); } var _whard = _context.WealthHardware.Include(r => r.WhardRegion).AsNoTracking(); _whard = _whard.Where(h => h.WhardId == id); ViewData["WhardMolEmployeeId"] = _ControlesItems.GetMOLEmployeesByRegion(_whard.First().WhardRegion.RegionId); ViewData["WhardOfficeId"] = _ControlesItems.GetOfficesByRegion(_whard.First().WhardRegion.RegionId); ViewData["WhardRegionId"] = new SelectList(_context.Region, "RegionId", "RegionName", wealthHardware.WhardRegionId); ViewData["WhardWcatId"] = new SelectList(_context.WealthCategories, "WcatId", "Wcatname", wealthHardware.WhardWcatId); ViewData["WhardWtypeId"] = new SelectList(_context.WealthTypes, "WtypeId", "WtypeName", wealthHardware.WhardWtypeId); return(View(wealthHardware)); }