SourcingContainerViewModel Map(SourcingContainer equipment)
        {
            SourcingContainerViewModel vm = new SourcingContainerViewModel();
            vm.Id = equipment.Id;
            vm.Code = equipment.Code;
            vm.EquipmentNumber = equipment.EquipmentNumber;
            vm.Name = equipment.Name;
            vm.Make = equipment.Make;
            vm.Model = equipment.Model;
            vm.EquipmentType = (int) EquipmentType.Container;
            ContainerType containerType = _containerTypeRepository.GetById(equipment.ContainerType.Id);
            vm.CostCentreName = equipment.CostCentre.Name;

            vm.ContainerType = containerType.Id;
            vm.ContainerTypeName = containerType.Name;
            vm.Description = equipment.Description;
            vm.CostCentre = equipment.CostCentre.Id;
            vm.IsActive = (int) equipment._Status;
            //vm.LoadCariage = equipment.LoadCariage;
            //vm.TareWeight = equipment.TareWeight;
            //vm.Length = equipment.Lenght;
            //vm.Width = equipment.Width;
            //vm.Height = equipment.Height;
            //vm.BubbleSpace = equipment.BubbleSpace;
            //vm.Volume = equipment.Volume;
            //vm.FreezerTemp = equipment.FreezerTemp;
            Guid grade = Guid.Empty;
            Guid commodity = Guid.Empty;
            string gradeName = "";
            //if(equipment.CommodityGrade==null)
            //{
            //}
            //else if (equipment.CommodityGrade != null)
            //{
            //    grade = equipment.CommodityGrade.Id;
            //    commodity = equipment.CommodityGrade.Commodity.Id;
            //    gradeName = equipment.CommodityGrade.Name;
            //}
           /* vm.CommodityGrade = grade;
            vm.IsActive = (int)equipment._Status;
            vm.CostCentreName = equipment.CostCentre.Name;
            vm.CommodityGradeName = gradeName;
            vm.CommodityId = commodity;*/


            return vm;
        }
        public void Save(SourcingContainerViewModel vm)
        {
            SourcingContainer sourcingContainer = new SourcingContainer(vm.Id);
            sourcingContainer.Name = vm.Name;
            sourcingContainer.Code = vm.Code;
            sourcingContainer.EquipmentNumber = vm.EquipmentNumber;
            sourcingContainer.Make = vm.Make;
            sourcingContainer.Model = vm.Model;
            sourcingContainer.EquipmentType = EquipmentType.Container;
           // sourcingContainer.ContainerType = (ContainerUserType)vm.ContainerType;
            sourcingContainer.Description = vm.Description;
            sourcingContainer.CostCentre = (Hub)_hubRepository.GetById(vm.CostCentre);// _producerRepository.GetById();
            sourcingContainer.ContainerType = _containerTypeRepository.GetById(vm.ContainerType);
            //sourcingContainer.LoadCariage = vm.LoadCariage;
            //sourcingContainer.TareWeight = vm.TareWeight;
            //sourcingContainer.Lenght = vm.Length;
            //sourcingContainer.Width = vm.Width;
            //sourcingContainer.Height = vm.Height;
            //sourcingContainer.BubbleSpace = vm.BubbleSpace;
            //sourcingContainer.Volume = vm.Volume;
            //sourcingContainer.FreezerTemp = vm.FreezerTemp;
           /* Commodity commodity = (Commodity) _commodityRepository.GetById((Guid) vm.CommodityId);
            if (vm.CommodityGrade==null)
            {

            }*/
           /* else if (vm.CommodityGrade != null)
            {
               // sourcingContainer.CommodityGrade = commodity.CommodityGrades.Where(n => n.Id == vm.CommodityGrade).FirstOrDefault();
            }*/
            sourcingContainer._Status =EntityStatus.Active;
            _equipmentRepository.Save(sourcingContainer);
        }