public DeviceViewModel ToDeviceViewModel(Movement movement)
 {
     return(new DeviceViewModel
     {
         DeviceId = movement.Device.Id,
         WareHouseManagerId = movement.Device.Inventory.WarehouseManager.Id,
         BrandId = movement.Device.Brand.Id,
         InventoryId = movement.Device.Inventory.Id,
         WareHouseId = movement.Device.Warehouse.Id,
         MovementTypeId = movement.MovementType.Id,
         DateInventary = movement.Device.Inventory.DateInventary,
         ListDevices = _combosHelper.GetComboDevices(),
         ListBrands = _combosHelper.GetComboBrands(),
         ListMovements = _combosHelper.GetComboMovementTypes(),
         CodeIntegral = movement.Device.CodeIntegral,
         CodeValorar = movement.Device.CodeValorar,
         SerialNumber = movement.Device.SerialNumber,
         Description = movement.Device.Description,
         IsActive = movement.Device.IsActive
     });
 }
Exemple #2
0
        public async Task <IActionResult> AddDeviceToInventory(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var inventory = await _dataContext.Inventories
                            .Include(i => i.Warehouse)
                            .Include(wm => wm.WarehouseManager)
                            .ThenInclude(u => u.User)
                            .Include(i => i.Devices)
                            .ThenInclude(b => b.Brand)
                            .ThenInclude(d => d.Devices)
                            .ThenInclude(dt => dt.DeviceType)
                            .ThenInclude(d => d.Devices)
                            .ThenInclude(m => m.Movements)
                            .ThenInclude(mt => mt.MovementType)
                            .FirstOrDefaultAsync(m => m.Id == id);

            if (inventory == null)
            {
                return(NotFound());
            }

            var model = new DeviceViewModel
            {
                WareHouseId        = inventory.Warehouse.Id,
                WareHouseManagerId = inventory.WarehouseManager.Id,
                DateInventary      = DateTime.Today,
                ListDevices        = _combosHelper.GetComboDevices(),
                ListBrands         = _combosHelper.GetComboBrands(),
                ListMovements      = _combosHelper.GetComboMovementTypes(),
                InventoryId        = inventory.Id
            };

            return(View(model));
        }