Exemplo n.º 1
0
        public async Task <ActionResultResponse <WarehouseDetailViewModel> > GetDetail(string tenantId, string warehouseId)
        {
            var info = await _warehouseRepository.GetInfo(warehouseId);

            if (info == null)
            {
                return(new ActionResultResponse <WarehouseDetailViewModel>(-1, _warehouseResourceService.GetString("Warehouse does not exists.")));
            }

            if (info.TenantId != tenantId)
            {
                return(new ActionResultResponse <WarehouseDetailViewModel>(-2, _sharedResourceService.GetString(ErrorMessage.NotHavePermission)));
            }

            var warehouseManagerConfigs = await _warehouseManagerConfigRepository.GetsWarehouseId(warehouseId, tenantId);

            //var warehouseLimits = await _warehouseLimitRepository.GetsWarehouseId(warehouseId, tenantId);

            var warehouseDetail = new WarehouseDetailViewModel
            {
                Id = info.Id,
                ConcurrencyStamp          = info.ConcurrencyStamp,
                IsActive                  = info.IsActive,
                Name                      = info.Name,
                Description               = info.Description,
                Address                   = info.Address,
                InventoryCalculatorMethod = await _warehouseConfigRepository.GetInventoryCalculatorMethod(tenantId, warehouseId),
                WarehouseManagerConfigs   = warehouseManagerConfigs?.Select(x => new WarehouseManagerConfigViewModel
                {
                    UserId      = x.UserId,
                    WarehouseId = x.WarehouseId,
                    FullName    = x.FullName,
                    Avatar      = x.Avatar,
                    PhoneNumber = x.PhoneNumber,
                    Permissions = x.Permissions,
                    CreateTime  = x.CreateTime
                }).ToList(),
                //WarehouseLimits = warehouseLimits?.Select(x => new WarehouseLimitViewModel
                //{
                //    WarehouseId = x.WarehouseId,
                //    ProductId = x.ProductId,
                //    ProductUnitId = x.ProductUnitId,
                //    Quantity = x.Quantity,
                //    CreateTime = x.CreateTime
                //}).ToList()
            };

            return(new ActionResultResponse <WarehouseDetailViewModel>
            {
                Code = 1,
                Data = warehouseDetail
            });
        }
 public WarehouseDetail()
 {
     VM          = new WarehouseDetailViewModel(this);
     DataContext = VM;
     InitializeComponent();
 }