public async Task <IHttpActionResult> Update([FromBody] QualityControlDto dto) { var user = await GetUserAsync(); var control = await _unitOfWork.QualityControlRepository.FindByIdAsync(dto.Id); if (control == null) { return(NotFound()); } try { control.Update(user, dto.Name, dto.Description); _unitOfWork.QualityControlRepository.Update(control); await _unitOfWork.SaveChangesAsync(); } catch (Exception ex) { await LogExceptionAsync(ex); return(BadRequest(ex.Message)); } return(Ok()); }
public QualityControl Create(QualityControlDto dto, User user) { return(new QualityControl(user) { ProductId = dto.Product, DefectId = dto.Defect, Name = dto.Name, Serial = dto.Serial, Description = dto.Description, Status = QualityControlStatus.Open, }); }
public async Task <IHttpActionResult> Create([FromBody] QualityControlDto dto) { var user = await GetUserAsync(); try { var control = _factory.Create(dto, user); _unitOfWork.QualityControlRepository.Add(control); await _unitOfWork.SaveChangesAsync(); } catch (Exception ex) { await LogExceptionAsync(ex); return(BadRequest(ex.Message)); } return(Ok()); }
protected override void InitializeMockData() { dto = new QualityControlDto { Id = 1, Name = "High tolerances", Description = "Dimensions DI310 and C220 out of upper tolerance.", Serial = "SN18972123", Defect = 1, Product = 1 }; control = new QualityControl(_user) { Id = 1, Name = "High tolerances", Description = "Dimensions DI310 and C220 out of upper tolerance.", Defect = new Defect { Name = "Scratch" }, Product = new Product { Name = "Blade F23" }, Instructions = new List <Instruction>(), Status = QualityControlStatus.InProgress }; secondControl = new QualityControl { Name = "MPI", Description = "Scratch in zone D3", Defect = new Defect { Name = "Scratch" }, Product = new Product { Name = "Blade F23" }, Status = QualityControlStatus.Open }; controls = new List <QualityControl>() { control, secondControl }; }