protected override bool LoadEntityDataBeforeCreate(ReportGroupItemForm model) { var prod = _context.Products.FirstOrDefault(p => p.Sku == model.Sku); if (prod == null) { ModelState.AddModelError("Sku", $"Sku '{model.Sku}' not found"); return(false); } model.ProductId = prod.Id; return(true); }
protected override void LoadRelatedCreateModelData(ReportGroupItemForm model) { model.ReportGroups = _context.ReportGroups.OrderBy(r => r.Name).Select(s => new { s.Id, s.Name }).ToList().Select(s => new SelectListItem(s.Name, s.Id.ToString())); if (Request.Method.ToLowerInvariant() == "get") { string reportGroupId = Request.Query["ReportGroupId"]; if (!reportGroupId.IsEmpty()) { model.ReportGroupId = int.Parse(reportGroupId); } } }
public override IActionResult Edit([FromRoute] int id, ReportGroupItemForm model) { throw new NotImplementedException(); }