public Item UpdateLegacyObject(Item item, IUoMService _uomService, IItemTypeService _itemTypeService, IWarehouseItemService _warehouseItemService, IWarehouseService _warehouseService, IBarringService _barringService, IContactService _contactService, IMachineService _machineService, IPriceMutationService _priceMutationService, IContactGroupService _contactGroupService) { Barring barring = _barringService.GetObjectById(item.Id); if (barring != null) { _barringService.UpdateObject(barring, _barringService, _uomService, this, _itemTypeService, _contactService, _machineService, _warehouseItemService, _warehouseService, _contactGroupService, _priceMutationService); return(barring); } if (_validator.ValidUpdateLegacyObject(item, _uomService, this, _itemTypeService)) { ContactGroup contactGroup = _contactGroupService.GetObjectByIsLegacy(true); Item olditem = _repository.GetObjectById(item.Id); // Note: olditem might be pointing to the same memory with item (share the same contents) PriceMutation oldpriceMutation = _priceMutationService.GetObjectById(item.PriceMutationId); if (olditem.SellingPrice != item.SellingPrice) { DateTime priceMutationTimeStamp = DateTime.Now; PriceMutation priceMutation = _priceMutationService.CreateObject(item, /*contactGroup,*/ priceMutationTimeStamp); item.PriceMutationId = priceMutation.Id; _priceMutationService.DeactivateObject(oldpriceMutation, priceMutationTimeStamp); } item = _repository.UpdateObject(item); } return(item); }
public Item UpdateLegacyObject(Item item, IUoMService _uomService, IItemTypeService _itemTypeService, IWarehouseItemService _warehouseItemService, IWarehouseService _warehouseService, IBarringService _barringService, IContactService _contactService, IMachineService _machineService) { Barring barring = _barringService.GetObjectById(item.Id); if (barring != null) { _barringService.UpdateObject(barring, _barringService, _uomService, this, _itemTypeService, _contactService, _machineService, _warehouseItemService, _warehouseService); return(barring); } return(item = _validator.ValidUpdateLegacyObject(item, _uomService, this, _itemTypeService) ? _repository.UpdateObject(item) : item); }
public dynamic Update(Barring model) { try { var data = _barringService.GetObjectById(model.Id); data.Name = model.Name; model = _barringService.UpdateObject(data, _barringService, _uomService, _itemService, _itemTypeService, _contactService, _machineService, _warehouseItemService, _warehouseService); } catch (Exception ex) { LOG.Error("Update Failed", ex); model.Errors.Add("Generic", "Error : " + ex); } return(Json(new { model.Errors })); }