public IActionResult GetStep(string stepIndex, int planId) { _loggerManager.Info($"GetStep({stepIndex},{planId}) is requested"); if (string.IsNullOrEmpty(stepIndex) || !_planRepository.GetStepList().Contains(stepIndex)) { _loggerManager.Warn($"GetStep({stepIndex},{planId}): Step Index is invalid"); return(BadRequest()); } if (!_planRepository.FindByCondition(x => x.Id == planId).Any()) { _loggerManager.Warn($"GetStep({stepIndex},{planId}): A plan with a such Id does not exist"); return(BadRequest()); } var userId = HttpContext.GetUserId(); var isDefinitive = User.IsInRole(Roles.Admin); if (!isDefinitive && !_planRepository.IsUserInPlanningTeam(planId, userId)) { _loggerManager.Warn($"GetStep({stepIndex},{planId}): an users is not authorized to access"); return(new StatusCodeResult(StatusCodes.Status401Unauthorized)); } if (!_planRepository.IsAvailableStep(planId, stepIndex)) { _loggerManager.Warn($"GetStep({stepIndex},{planId}): The step is not avalaible"); return(BadRequest()); } var stepDTO = _planRepository.GetStep(stepIndex, planId, isDefinitive, userId); if (stepDTO == null) { _loggerManager.Error($"GetStep({stepIndex},{planId}): Internal error "); return(new StatusCodeResult(StatusCodes.Status500InternalServerError)); } _loggerManager.Info($"GetStep({stepIndex},{planId}): Successfully returned step"); return(View("Step", stepDTO)); }