Example #1
0
        public List <UserDto> GetUsers()
        {
            var userDtos = userService.GetUsers();

            var supplierBases      = supplierBaseBusinessEntity.GetAllActiveSupplierBases();
            var deliverySlots      = deliverySlotsBusinessEntity.GetDeliverySlots();
            var standaradInventory = standardInventoryBusinessEntity.GetStandardInventories();
            var zones = zoneBusinessEntity.GetZones();

            var userDtoList = userDtos.Select(p => new UserDto()
            {
                ID       = p.ID, Name = p.Name, Address = p.Address, ContactNo = p.ContactNo,
                Email    = p.Email, UserType = p.UserType, DefaultSupplierBaseId = p.DefaultSupplierBaseId, DeliverySlotId = p.DeliverySlotId,
                Category = p.Category, StandaradInventoryID = p.StandaradInventoryID, RelevantZoneId = p.RelevantZoneId
            }).ToList();

            userDtoList.ForEach(p => {
                var supplierBase = supplierBases.FirstOrDefault(s => s.SupplierBaseId == p.DefaultSupplierBaseId);

                if (supplierBase != null)
                {
                    p.DefaultSupplierBaseName = supplierBase.SupplierBaseName;
                }
            });
            userDtoList.ForEach(p => {
                var deliverySlot = deliverySlots.FirstOrDefault(s => s.ID == p.DeliverySlotId);

                if (deliverySlot != null)
                {
                    p.DeliverySlotName = deliverySlot.SlotName;
                }
            });
            userDtoList.ForEach(p => {
                var supplierStandardInventories = standaradInventory.FirstOrDefault(s => s.ID == p.StandaradInventoryID);

                if (supplierStandardInventories != null)
                {
                    p.StandaradInventoryName = supplierStandardInventories.ItemName;
                }
            });
            userDtoList.ForEach(p =>
            {
                var zone = zones.FirstOrDefault(s => s.ID == p.RelevantZoneId);
                if (zone != null)
                {
                    p.RelevantZoneName = zone.Name;
                }
            });


            return(userDtoList);
        }
Example #2
0
        public List <ZoneDto> GetZones()
        {
            var zone         = iZoneDataService.GetAllZone();
            var supplierBase = supplierBaseBusinessEntity.GetAllActiveSupplierBases();

            var zoneDtoList = zone.Select(z => new ZoneDto()
            {
                ID             = z.ID,
                SupplierBaseID = z.SupplierBaseID,
                Name           = z.Name,
                Description    = z.Description
            }).ToList();

            zoneDtoList.ForEach(z =>
            {
                var supplierBases = supplierBase.FirstOrDefault(s => s.SupplierBaseId == z.SupplierBaseID);
                if (supplierBases != null)
                {
                    z.SupplierBaseName = supplierBases.SupplierBaseName;
                }
            });
            return(zoneDtoList);
        }