Exemplo n.º 1
0
        public async Task <ActionResult> RequestControl(QualityControlViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                viewModel.Products = await _unitOfWork.ProductRepository.GetAllAsync();

                viewModel.Defects = await _unitOfWork.DefectRepository.GetAllAsync();

                return(View(viewModel));
            }

            try
            {
                var user = await GetUserAsync();

                var control = _factory.Create(viewModel, user);
                _unitOfWork.QualityControlRepository.Add(control);
                await _unitOfWork.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                await LogExceptionAsync(ex);

                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, ex.Message));
            }

            return(RedirectToAction("Index", "QualityControl"));
        }
        protected override void InitializeMockData()
        {
            desicion = new Desicion {
                Id = 1, Name = "Rejected"
            };

            _mockControl = new QualityControl(_user)
            {
                Id     = 1,
                Name   = "High tolerances",
                Status = QualityControlStatus.Open,
                Defect = new Defect {
                    Name = "DI110", Description = "Out of tolerances"
                },
                Product = new Product {
                    Name = "Blade", Description = "blade fb1"
                }
            };
            controls = new List <QualityControl>
            {
                _mockControl,
                new QualityControl {
                    Name        = "Documental deviation",
                    Description = "Prox p40",
                    Product     = new Product {
                        Name = "CFM Fan Blade"
                    },
                    Defect = new Defect {
                        Name = "DEQ"
                    },
                    Inspection = new Inspection {
                        Desicion = desicion
                    }
                }
            };

            viewModel = new QualityControlViewModel
            {
                Name        = "High tolerances",
                Description = "Dimensions DI310 and C220 out of upper tolerance.",
                Serial      = "SN18972123",
                Defect      = 1,
                Product     = 1
            };
            detailViewModel = new QualityControlDetailViewModel
            {
                Id          = 1,
                Name        = "No-conforming dimensions",
                Description = "Dimension DI110 is out of upper tolerance."
            };

            expectedRedirectValues = new RouteValueDictionary
            {
                { "action", "Index" },
                { "controller", "QualityControl" }
            };
        }
Exemplo n.º 3
0
        public async Task <ActionResult> RequestControl()
        {
            var viewModel = new QualityControlViewModel
            {
                Products = await _unitOfWork.ProductRepository.GetAllAsync(),
                Defects  = await _unitOfWork.DefectRepository.GetAllAsync()
            };

            return(View(viewModel));
        }
Exemplo n.º 4
0
 public QualityControl Create(QualityControlViewModel model, User user)
 {
     return(new QualityControl(user)
     {
         ProductId = model.Product,
         DefectId = model.Defect,
         Name = model.Name,
         Serial = model.Serial,
         Description = model.Description,
         Status = QualityControlStatus.Open,
     });
 }
Exemplo n.º 5
0
 public QualityControlRegistration()
 {
     InitializeComponent();
     _qualityViewModel = new QualityControlViewModel();
     this.DataContext  = _qualityViewModel;
 }