// To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } Craftsmen = (await _craftsmanClient.GetAll()).ToList(); var craftsman = Craftsmen.First(toolbo => toolbo.CraftsmanId == Toolbox.OwnerId); craftsman.ToolBoxes.Add(Toolbox); var exists = await _toolboxClient.Get(Toolbox.ToolboxId); if (exists == null) { await _toolboxClient.Insert(Toolbox); } else { Toolbox.Tools = exists.Tools; } await _toolboxClient.Update(Toolbox.ToolboxId, Toolbox); await _craftsmanClient.Update(craftsman.CraftsmanId, craftsman); return(RedirectToPage("./Index")); }
// To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } ToolBox = (await _toolboxClient.GetAll()).ToList(); var toolbox = ToolBox.First(toolbo => toolbo.ToolboxId == Tool.ToolBoxId); toolbox.Tools.Add(Tool); await _toolClient.Insert(Tool); await _toolboxClient.Update(toolbox.ToolboxId, toolbox); return(RedirectToPage("./Index")); }