public IndicationService(IndicationRepository repository, ProductRepository productRepository, UserRepository userRepository, CnpjValidate cnpjValidate, CpfValidate cpfValidate) { _repository = repository; _productRepository = productRepository; _userRepository = userRepository; _cnpjValidate = cnpjValidate; _cpfValidate = cpfValidate; }
public void Add([FromBody] IndicationsDeviceData indicationsDeviceData) { IndicationRepository indicationRepository = new IndicationRepository(); using (indicationRepository) { var newIndication = new Indication() { Temperature = indicationsDeviceData.Temperature, Humidity = indicationsDeviceData.Humidity, WorkDateTime = new DateTime() }; indicationRepository.Add(newIndication, indicationsDeviceData.MAC); } }
public IActionResult Info(int id) { DeviceRepository deviceRepository = new DeviceRepository(); ProductRepository productRepository = new ProductRepository(); EmployeeRepository employeeRepository = new EmployeeRepository(); OrderRepository orderRepository = new OrderRepository(); IndicationRepository indicationRepository = new IndicationRepository(); using (orderRepository) using (deviceRepository) using (productRepository) using (employeeRepository) using (indicationRepository) { ViewBag.Employees = Mapper.Map <List <EmployeeModel> >(employeeRepository.ReadAll()); ViewBag.Products = Mapper.Map <List <ProductModel> >(productRepository.ReadAll()); ViewBag.Devices = Mapper.Map <List <DeviceModel> >(deviceRepository.ReadAll()); var order = Mapper.Map <OrderModel>(orderRepository.Read(id)); var indications = Mapper.Map <List <IndicationModel> >(indicationRepository.Read(Mapper.Map <Order>(order))); var productViewDataList = new List <ProductViewData>(); foreach (var product in order.Products) { productViewDataList.Add(new ProductViewData(product, indications)); } ViewBag.productViewDataList = productViewDataList; return(View(order)); } }