Esempio n. 1
0
        public async Task GetProgress(int id, int stepNum, string action)
        {
            var step = await _repo.GetUpdateSteps(stepNum, id);

            var updatechecklist = await _repo.GetUpdate(step.Idupdate);

            step.Progress = action;
            switch (action)
            {
            case "Done":

                LogHistory(step, updatechecklist.Status, "Completed Step ");
                break;

            case "Skip":
                step.Progress = "Skip";
                LogHistory(step, updatechecklist.Status, "Skipped Step ");
                break;

            case "":
                step.Progress = "";
                LogHistory(step, updatechecklist.Status, "Unchecked Step ");
                break;
            }
            await _repo.SaveAll();

            var percentage = Helpers.Helpers.GetPercentage(updatechecklist);
            await Clients.All.SendAsync("StepProgress", step.Progress, step.Step, step.Comment, percentage);
        }
        public async Task <ActionResult> ChecklistAction(int updateId, int stepId, [FromQuery] string action)
        {
            var step = await _repo.GetUpdateSteps(stepId, updateId);

            var status = _repo.GetStatus(updateId);

            if (step == null)
            {
                BadRequest("Step does not exist");
            }
            switch (action)
            {
            case "complete":
                step.Progress = "Done";
                LogHistory(step, status, "Completed Step ");
                break;

            case "skip":
                step.Progress = "Skip";
                LogHistory(step, status, "Skipped Step ");
                break;

            case "clear":
                step.Progress = "";
                LogHistory(step, status, "Unchecked Step ");
                break;
            }
            if (await _repo.SaveAll())
            {
                return(NoContent());
            }
            return(BadRequest("Error Saving, Please Try again"));
        }