Example #1
0
        public static async Task <Blueprint> EditAsync(StartEditCommand cmd)
        {
            var blueprint = await Repository.LoadAsync <Blueprint>(cmd.BlueprintId);

            blueprint.Update(cmd);
            return(blueprint);
        }
Example #2
0
        public async Task <IActionResult> StartEdit(StartEditCommand cmd)
        {
            cmd.OwnedByUserId = HttpContext.LoggedInUser().Id;

            return(await ExecAsync(cmd,
                                   success : blueprint => this.ReturnModal(),
                                   failure : () => RenderStartEdit(cmd)));
        }
Example #3
0
        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;
        }
Example #4
0
        public static async Task <Blueprint> StartAsync(StartEditCommand cmd)
        {
            var blueprint = new Blueprint
            {
                OwnedByUserId = cmd.OwnedByUserId,
            };

            blueprint.Update(cmd);
            return(await Repository.SaveAsync(blueprint));
        }
Example #5
0
        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));
        }
Example #6
0
        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));
        }