public async Task <IActionResult> Edit(Guid id, [Bind("FromStoreId,ToStoreId,FromDate,ToDate,FromCagId,ToCagId,Descr,Id")] DocHead docHead) { if (id != docHead.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(docHead); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DocHeadExists(docHead.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["FromCagId"] = new SelectList(_context.Cags, "Id", "Descr", docHead.FromCagId); ViewData["FromStoreId"] = new SelectList(_context.Stores, "Id", "Descr", docHead.FromStoreId); ViewData["ToCagId"] = new SelectList(_context.Cags, "Id", "Descr", docHead.ToCagId); ViewData["ToStoreId"] = new SelectList(_context.Stores, "Id", "Descr", docHead.ToStoreId); return(View(docHead)); }
public async Task <IActionResult> CreateDoc(DocHead item) { ModelState["Id"].ValidationState = ModelValidationState.Valid; if (item != null && ModelState.IsValid) { _db.Add(item); await _db.SaveChangesAsync(); } return(Json(new[] { item }.ToDataSourceResult(new DataSourceRequest(), ModelState))); }
public ActionResult Destroy([DataSourceRequest] DataSourceRequest request, DocHead item) { if (!_db.DocLines.Any(x => x.DocHeadId == item.Id)) { _db.Remove(item); _db.SaveChanges(); } return(Json(ModelState.ToDataSourceResult())); }
public ActionResult UpdateDoc([DataSourceRequest] DataSourceRequest request, DocHead item) { ModelState["Id"].ValidationState = ModelValidationState.Valid; if (item != null && ModelState.IsValid) { _db.Update(item); _db.SaveChanges(); } return(Json(new[] { item }.ToDataSourceResult(request, ModelState))); }
public async Task <IActionResult> Create([Bind("FromStoreId,ToStoreId,FromDate,ToDate,FromCagId,ToCagId,Descr,Id")] DocHead docHead) { if (ModelState.IsValid) { docHead.Id = Guid.NewGuid(); _context.Add(docHead); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["FromCagId"] = new SelectList(_context.Cags, "Id", "Descr", docHead.FromCagId); ViewData["FromStoreId"] = new SelectList(_context.Stores, "Id", "Descr", docHead.FromStoreId); ViewData["ToCagId"] = new SelectList(_context.Cags, "Id", "Descr", docHead.ToCagId); ViewData["ToStoreId"] = new SelectList(_context.Stores, "Id", "Descr", docHead.ToStoreId); return(View(docHead)); }