Ejemplo n.º 1
0
        public CoreBuilder UpdateObject(CoreBuilder coreBuilder, IUoMService _uomService, IItemService _itemService, IItemTypeService _itemTypeService,
                                        IWarehouseItemService _warehouseItemService, IWarehouseService _warehouseService, IBarringService _barringService,
                                        IContactService _contactService, IMachineService _machineService, IPriceMutationService _priceMutationService,
                                        IContactGroupService _contactGroupService)
        {
            Item UsedCore = _itemService.GetObjectById(coreBuilder.UsedCoreItemId);

            UsedCore.Name     = coreBuilder.Name;
            UsedCore.Category = coreBuilder.Category;
            Item NewCore = _itemService.GetObjectById(coreBuilder.NewCoreItemId);

            NewCore.Name     = coreBuilder.Name;
            NewCore.Category = coreBuilder.Category;

            if (_itemService.GetValidator().ValidUpdateLegacyObject(UsedCore, _uomService, _itemService, _itemTypeService) &&
                _itemService.GetValidator().ValidUpdateLegacyObject(NewCore, _uomService, _itemService, _itemTypeService))
            {
                if (_validator.ValidUpdateObject(coreBuilder, this, _uomService, _itemService))
                {
                    _itemService.UpdateLegacyObject(UsedCore, _uomService, _itemTypeService, _warehouseItemService, _warehouseService,
                                                    _barringService, _contactService, _machineService, _priceMutationService, _contactGroupService);
                    _itemService.UpdateLegacyObject(NewCore, _uomService, _itemTypeService, _warehouseItemService, _warehouseService,
                                                    _barringService, _contactService, _machineService, _priceMutationService, _contactGroupService);
                    coreBuilder = _repository.UpdateObject(coreBuilder);
                }
            }
            else
            {
                if (UsedCore.Errors.Count() > 0)
                {
                    coreBuilder.Errors.Add(UsedCore.Errors.First().Key, UsedCore.Errors.First().Value);
                }
                else if (NewCore.Errors.Count() > 0)
                {
                    coreBuilder.Errors.Add(NewCore.Errors.First().Key, NewCore.Errors.First().Value);
                }
                else
                {
                    coreBuilder.Errors.Add("Generic", "Item tidak dapat di update");
                }
            }
            return(coreBuilder);
        }
Ejemplo n.º 2
0
        public CoreBuilder UpdateObject(CoreBuilder coreBuilder, IUoMService _uomService, IItemService _itemService, IItemTypeService _itemTypeService)
        {
            Item UsedCore = _itemService.GetObjectById(coreBuilder.UsedCoreItemId);

            UsedCore.Name     = coreBuilder.Name;
            UsedCore.Category = coreBuilder.Category;
            Item NewCore = _itemService.GetObjectById(coreBuilder.NewCoreItemId);

            NewCore.Name     = coreBuilder.Name;
            NewCore.Category = coreBuilder.Category;

            if (_itemService.GetValidator().ValidUpdateLegacyObject(UsedCore, _uomService, _itemService, _itemTypeService) &&
                _itemService.GetValidator().ValidUpdateLegacyObject(NewCore, _uomService, _itemService, _itemTypeService))
            {
                if (_validator.ValidUpdateObject(coreBuilder, this, _uomService, _itemService))
                {
                    _itemService.GetRepository().UpdateObject(UsedCore);
                    _itemService.GetRepository().UpdateObject(NewCore);
                    coreBuilder = _repository.UpdateObject(coreBuilder);
                }
            }
            else
            {
                if (UsedCore.Errors.Count() > 0)
                {
                    coreBuilder.Errors.Add(UsedCore.Errors.First().Key, UsedCore.Errors.First().Value);
                }
                else if (NewCore.Errors.Count() > 0)
                {
                    coreBuilder.Errors.Add(NewCore.Errors.First().Key, NewCore.Errors.First().Value);
                }
                else
                {
                    coreBuilder.Errors.Add("Generic", "Item tidak dapat di update");
                }
            }
            return(coreBuilder);
        }