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"));
        }
Пример #2
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);
        }
Пример #3
0
        public async Task <ActionResult> StartUpdate(LogUpdate updateChecklist)
        {
            var checklist = await _repo.UpdateExists(updateChecklist);

            if (checklist != null)
            {
                return(BadRequest($"{updateChecklist.Process} {updateChecklist.SiteKml} already exists. Please Try again"));
            }
            updateChecklist.StartTime = DateTime.Now;
            updateChecklist.Status    = "In Progress";
            _repo.Add(updateChecklist);
            var steps = await _repo.GetSteps(updateChecklist.Idchecklist, updateChecklist.Version);

            foreach (var s in steps)
            {
                var step = new LogUpdateSteps
                {
                    Step     = s.Step,
                    StepText = s.StepText,
                    Title    = s.Title,
                    Idupdate = updateChecklist.Idupdate
                };

                _repo.Add(step);
            }
            if (await _repo.SaveAll())
            {
                return(CreatedAtAction("GetUpdate", new { id = updateChecklist.Idupdate }, updateChecklist));
            }

            return(BadRequest("Failed to Create Update"));
        }