//TODO Remove public IHttpActionResult UpdateInstruction(InstructionDto instructionDto) { if (!ModelState.IsValid) { return(BadRequest()); } var recipe = _service.GetTempRecipe("tempRecipe"); var instruction = recipe.Instructions.FirstOrDefault(c => c.Id == instructionDto.Id); if (instruction != null) { instruction.Name = instructionDto.Name; } else { return(BadRequest()); } instructionDto = Mapper.Map <Instruction, InstructionDto>(instruction); _service.SetTempRecipe("tempRecipe", recipe); return(Ok(instructionDto)); }
public async Task <IHttpActionResult> AddInstructionAsync([FromBody] InstructionDto dto) { var qualityControl = await _unitOfWork.QualityControlRepository.FindByIdAsync(dto.QualityControlId); if (qualityControl == null) { return(NotFound()); } try { var user = await GetUserAsync(); var instruction = _factory.Create(dto, user); qualityControl.AddInstruction(instruction, user); await _unitOfWork.SaveChangesAsync(); return(Ok(instruction)); } catch (Exception ex) { await LogExceptionAsync(ex); return(BadRequest(ex.Message)); } }
public void initializeTest() { instruct = new InstructionDto(); var advent1 = new Adventurer { PosX = 0, PosY = 0, MovementList = "A", Name = "Indiana", FinishMoving = false, PlayerOrientation = "S", Treasures = 0 }; var advent2 = new Adventurer { PosX = 3, PosY = 3, MovementList = "ADDGA", Name = "Shia", FinishMoving = false, PlayerOrientation = "O", Treasures = 0 }; instruct.adventurer = new List <IAdventurer> { advent1, advent2 }; instruct.mapSizeX = 5; instruct.mapSizeY = 5; var mountain = new Mountain(1, 1) { GotAdventurer = false, tileType = TileType.MOUNTAIN }; var treasure = new Treasure(2, 2, 2) { GotAdventurer = false, tileType = TileType.TREASURE }; instruct.tiles = new List <ITile> { mountain, treasure }; map = new Map(5, 5); loopClassTest = new LoopClass(map); //Assert }
public Instruction Create(InstructionDto model, User user) { return(new Instruction(user) { QualityControlId = model.QualityControlId, Name = model.Name, Description = model.Description, Comments = model.Comments, Status = InstructionStatus.Pending }); }
private static Step MapStep(InstructionDto instructionData) { var stripHtml = new Regex("<[^>]*(>|$)"); var instructionHtml = instructionData.Text; var instructionText = stripHtml.Replace(instructionHtml, string.Empty); return(new Step { Text = instructionText.Replace("\n", " ") }); }
public void Edit(InstructionDto instructionDto) { if (instructionDto == null) { throw new ArgumentNullException("instructionDto"); } var instruction = Mapper.Map <Instruction>(instructionDto); Database.Instructions.Update(instruction); Database.Save(); }
public void Add(InstructionDto instructionDto) { if (instructionDto == null) { throw new ArgumentNullException("instructionDto"); } var instruction = Mapper.Map <Instruction>(instructionDto); instruction.DateOfAdding = DateTime.Now; Database.Instructions.Add(instruction); Database.Save(); }
//TODO Remove public IHttpActionResult AddInstruction(InstructionDto instructionDto) { var recipe = _service.GetTempRecipe("tempRecipe"); var instruction = new Instruction(); instruction.Number = recipe.Instructions.Count + 1; instruction.Name = instructionDto.Name; instruction.Id = recipe.Instructions.Count + 1; recipe.Instructions.Add(instruction); _service.SetTempRecipe("tempRecipe", recipe); return(Ok()); }
protected override void InitializeMockData() { instructionDto = new InstructionDto { Name = "Dimensional Control", Description = "Control Dimensions DI010 and DI0320", QualityControlId = 1 }; instruction = new Instruction { Id = 1, Name = "CMM Control", Description = "remeasure DI010 and DI0320", QualityControlId = 1, Status = InstructionStatus.Performed }; secondInstruction = new Instruction { Id = 1, Name = "Shipping", Description = "Shipping Product", QualityControlId = 1, Status = InstructionStatus.Pending }; control = new QualityControl { Id = 1, Name = "High tolerances", Defect = new Defect { Name = "Dimensional" }, Status = QualityControlStatus.Open, Instructions = new List <Instruction>() { instruction, secondInstruction } }; instruction.QualityControl = control; }