Пример #1
0
        public SingleObjectModel GetStep([FromUri] string stepUID)
        {
            using (var usecases = StepsDesignUseCases.UseCaseInteractor()) {
                StepDto stepDto = usecases.GetStep(stepUID);

                return(new SingleObjectModel(this.Request, stepDto));
            }
        }
Пример #2
0
 public IActionResult Create(StepDto model)
 {
     if (ModelState.IsValid)
     {
         _stepManager.AddDTO <StepDto>(model);
         _stepManager.SaveChanges();
         return(Ok());
     }
     return(BadRequest("Error occured, try again"));
 }
Пример #3
0
 /// <summary>
 ///    From Step dto To Step pivot.
 /// </summary>
 /// <param name="stepDto">step dto to assemble.</param>
 /// <returns>Steppivot result.</returns>
 public static StepPivot ToPivot(this StepDto stepDto)
 {
     if (stepDto == null)
     {
         return(null);
     }
     return(new StepPivot
     {
         StepId = stepDto.StepId,
         StepDate = stepDto.StepDate,
     });
 }
 private void AssertStep(StepDto step, string title, int modeId, int responsibleId, string modeTitle, string responsibleCode, bool isVoided, bool forSupplier)
 {
     Assert.IsNotNull(step.Mode);
     Assert.AreEqual(forSupplier, step.Mode.ForSupplier);
     Assert.IsNotNull(step.Responsible);
     Assert.AreEqual(title, step.Title);
     Assert.AreEqual(isVoided, step.IsVoided);
     Assert.AreEqual(modeId, step.Mode.Id);
     Assert.AreEqual(modeTitle, step.Mode.Title);
     Assert.AreEqual(responsibleId, step.Responsible.Id);
     Assert.AreEqual(responsibleCode, step.Responsible.Code);
 }
Пример #5
0
        public StepResultDto MakeStep(StepDto newStep)
        {
            var game = _dbContext.Set <Game>()
                       .Where(x => x.Id == newStep.GameId)
                       .Include(x => x.Steps)
                       .First();

            var tickTackToeGame = new TickTackToeGame(game.Steps);

            tickTackToeGame.MakeStep(newStep.Coordinates.X, newStep.Coordinates.Y, game.UserPlayerType);
            var winnerDto = tickTackToeGame.TryGetWinner();
            var step      = new Step()
            {
                GameId = game.Id,
                Player = game.UserPlayerType,
                X      = newStep.Coordinates.X,
                Y      = newStep.Coordinates.Y,
            };

            _dbContext.Add(step);

            CoordinatesDto newStepCoordinates = null;

            if (winnerDto.Winner == null && !winnerDto.IsDraw)
            {
                var botPlayerType = game.UserPlayerType == PlayerType.X ? PlayerType.O : PlayerType.X;

                newStepCoordinates = tickTackToeGame.MakeBotStep(botPlayerType);
                winnerDto          = tickTackToeGame.TryGetWinner();

                var botStep = new Step()
                {
                    GameId = game.Id,
                    Player = botPlayerType,
                    X      = newStepCoordinates.X,
                    Y      = newStepCoordinates.Y,
                };
                _dbContext.Add(botStep);
            }

            game.Winner     = winnerDto.Winner;
            game.IsFinished = winnerDto.Winner != null || winnerDto.IsDraw;


            _dbContext.SaveChanges();

            return(new StepResultDto
            {
                Winner = winnerDto.Winner,
                BotStep = newStepCoordinates,
                IsFinished = game.IsFinished
            });
        }
Пример #6
0
        private void ExecuteAdd()
        {
            var stepDto = new StepDto()
            {
                Description = "Новый шаг"
            };

            _data.Steps.Add(stepDto);
            var stepViewModel = new StepViewModel(stepDto);

            Steps.Add(stepViewModel);
            SelectedStep = stepViewModel;
        }
Пример #7
0
        public IActionResult GetStepById(int stepId)
        {
            var step = _stepRepository.GetStep(stepId);

            if (step == null)
            {
                ModelState.AddModelError("", "Error getting a category");
                ViewBag.Message = $"There was a problem retrieving step with id {stepId} " +
                                  $"from the database or no step with that id exists";
                step = new StepDto();
            }
            return(View(step));
        }
Пример #8
0
 public ActionResult Save(StepDto model)
 {
     if (ModelState.IsValid)
     {
         var Step = new Step();
         _Step.Save(model);
         return(RedirectToAction("List"));
     }
     else
     {
         return(RedirectToAction("Create", model));
     }
 }
Пример #9
0
        public void RecordStep(ScenarioContext scenarioContext, FeatureContext featureContext)
        {
            var stepContext = scenarioContext.StepContext;

            if (featureContext.TryGetValue(out FeatureDto featureDto) && featureDto.Scenarios.TryGetValue(GetScenarioTitle(scenarioContext), out ScenarioDto scenario))
            {
                StepDto step = new StepDto()
                {
                    Title = $"{stepContext.StepInfo.StepDefinitionType} {stepContext.StepInfo.Text}"
                };
                scenario.Steps.Add(step);
            }
        }
Пример #10
0
 public IActionResult Update([FromBody] StepDto model)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     else
     {
         var step = _stepManager.GetById(model.Id);
         if (step == null)
         {
             return(NotFound($"there is no step with id: {model.Id}"));
         }
         _stepManager.UpdateDTO <StepDto>(model);
         _stepManager.SaveChanges();
         return(Ok());
     }
 }
Пример #11
0
        public IActionResult GetStep(int stepId)
        {
            if (!_stepRepository.StepExists(stepId))
            {
                return(NotFound());
            }

            var step = _stepRepository.GetStep(stepId);

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var stepDto = new StepDto()
            {
                Id          = step.Id,
                Description = step.Description
            };

            return(Ok(stepDto));
        }
Пример #12
0
        public StepDto GetStep(int stepId)
        {
            StepDto step = new StepDto();

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://localhost:49951/api/");

                var response = client.GetAsync($"steps/{stepId}");
                response.Wait();

                var result = response.Result;

                if (result.IsSuccessStatusCode)
                {
                    var readTask = result.Content.ReadAsAsync <StepDto>();
                    readTask.Wait();

                    step = readTask.Result;
                }
            }

            return(step);
        }
Пример #13
0
        /// <summary>
        /// Gets step list.
        /// </summary>
        /// <param name="sr">The reader.</param>
        /// <param name="stepList">The step list.</param>
        private static void GetStepList(SafeDataReader sr, List<StepDto> stepList)
        {
            while (sr.Read())
            {
                var fieldEditorDto = new StepDto
                {
                    Id = sr.GetInt("Id"),
                    StepId = sr.GetInt("Id"),
                    Name = sr.GetString("Name"),
                    Class = sr.GetString("Class"),
                    FieldId = sr.GetInt32("FieldId"),
                    StepNumber = sr.GetInt("StepNumber"),
                    ViewClass = sr.GetString("ViewClass")
                };

                stepList.Add(fieldEditorDto);
            }
        }
        public void Should_Get_A_Step()
        {
            StepDto process = _usecases.GetStep(TestingConstants.STEP_UID);

            Assert.Equal(TestingConstants.STEP_UID, process.UID);
        }
Пример #15
0
 /// <summary>
 /// Salva e retorna o objeto<T> salvo
 /// </summary>
 public virtual StepDto SaveGetItem(StepDto model)
 {
     _unitOfWork.GetRepository <StepDto>().Add(model);
     return(model);
 }
Пример #16
0
 public StepViewModel(StepDto step)
 {
     Data = step;
 }
Пример #17
0
        /// <summary>
        /// Gets field id.
        /// </summary>
        /// <param name="process">The process.</param>
        /// <param name="sr">The reader.</param>
        /// <param name="fieldId">The field id.</param>
        /// <param name="fieldDto">The field DTO.</param>
        /// <param name="stepFetchers">The step fetchers.</param>
        /// <param name="fieldEditorDto">The field editor DTO.</param>
        /// <returns>The Field Id.</returns>
        private static int? FieldId(
            ProcessEditDto process,
            SafeDataReader sr,
            int? fieldId,
            ref FieldDto fieldDto,
            Dictionary<string, IFetcher> stepFetchers,
            StepDto fieldEditorDto)
        {
            Profiler.Profile(() => sr.NextResult());

            if (fieldId != fieldEditorDto.FieldId)
            {
                fieldId = fieldEditorDto.FieldId;
                fieldDto = process.Sections.SelectMany(s => s.FieldList).First(f => f.Id == fieldId);
            }

            fieldDto.Editors.Add((BaseStepDto) (stepFetchers.ContainsKey(fieldEditorDto.Class)
                                                    ? stepFetchers[fieldEditorDto.Class].Fetch(fieldEditorDto, sr)
                                                    : fieldEditorDto));
            return fieldId;
        }
Пример #18
0
        public IActionResult MakeStep(StepDto newStep)
        {
            var result = _gameService.MakeStep(newStep);

            return(Ok(result));
        }
Пример #19
0
 /// <summary>
 /// Salva a edição de um objeto<T>
 /// </summary>
 public virtual void Update(StepDto model)
 {
     _unitOfWork.GetRepository <StepDto>().Update(model);
 }
Пример #20
0
 public CreateStepCommandResponse(StepDto step) => Step = step;
Пример #21
0
 /// <summary>
 /// Salva um objeto<T>
 /// </summary>
 public virtual void Save(StepDto model)
 {
     _unitOfWork.GetRepository <StepDto>().Add(model);
 }