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));
        }
Exemplo n.º 2
0
 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)));
 }
Exemplo n.º 3
0
 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()));
 }
Exemplo n.º 4
0
 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));
        }