Beispiel #1
0
        public async Task <ActionResult <BinDto> > CreateBin(CreateBinDto createBinDto)
        {
            var creator = User.GetUserName();
            var binType = await _binTypeRepository.GetBinTypeByName(createBinDto.TypeName);

            var warehouserLocation = await _warehouseLocationRepository.GetWarehouseLocationByName(createBinDto.LocationName);

            var bin = new Bin
            {
                Creator           = creator,
                BinReference      = createBinDto.BinReference,
                BinCode           = createBinDto.BinCode,
                BinType           = binType,
                WarehouseLocation = warehouserLocation
            };

            _binRepository.AddBin(bin);

            if (await _binRepository.SaveAllAsync())
            {
                return(Ok(_mapper.Map <BinDto>(bin)));
            }

            return(BadRequest("Failed to add bin."));
        }
        public async Task <ActionResult <WarehouseLocationDto> > GetWarehouseLocationByName(string name)
        {
            var wl = await _warehouseLocationRepository.GetWarehouseLocationByName(name);

            return(Ok(_mapper.Map <WarehouseLocationDto>(wl)));
        }