public static async Task <Blueprint> EditAsync(StartEditCommand cmd) { var blueprint = await Repository.LoadAsync <Blueprint>(cmd.BlueprintId); blueprint.Update(cmd); return(blueprint); }
public async Task <IActionResult> StartEdit(StartEditCommand cmd) { cmd.OwnedByUserId = HttpContext.LoggedInUser().Id; return(await ExecAsync(cmd, success : blueprint => this.ReturnModal(), failure : () => RenderStartEdit(cmd))); }
protected virtual void Update(StartEditCommand cmd) { if (OwnedByUserId != cmd.OwnedByUserId) { throw new Exception("Invalid attempt to change the owner of a Blueprint"); } VerifyNameIsUnique(Id, OwnedByUserId, cmd.Name); Name = cmd.Name; }
public static async Task <Blueprint> StartAsync(StartEditCommand cmd) { var blueprint = new Blueprint { OwnedByUserId = cmd.OwnedByUserId, }; blueprint.Update(cmd); return(await Repository.SaveAsync(blueprint)); }
public async Task <IActionResult> StartEdit(int blueprintId) { var cmd = new StartEditCommand { BlueprintId = blueprintId }; if (blueprintId != 0) { var blueprint = await ExecAsync(new FindBlueprintQuery { BlueprintId = blueprintId }); cmd.Name = blueprint.Name; } return(RenderStartEdit(cmd)); }
private IActionResult RenderStartEdit(StartEditCommand cmd) { var model = new StartEditModel { Cmd = cmd, }; if (cmd.BlueprintId == 0) { model.Title = "Start Blueprint"; model.ButtonText = "Start Blueprint"; } else { model.Title = "Edit Blueprint"; model.ButtonText = "Update"; } return(View(model)); }