internal IFacadeUpdateResult <ShipToData> SaveShipTo(ShipToDto dto) { ArgumentValidator.IsNotNull("dto", dto); FacadeUpdateResult <ShipToData> result = new FacadeUpdateResult <ShipToData>(); IShipToService service = UnitOfWork.GetService <IShipToService>(); ShipTo instance = RetrieveOrNew <ShipToData, ShipTo, IShipToService>(result.ValidationResult, dto.Id); if (result.IsSuccessful) { instance.Code = dto.Code; instance.CustomerId = dto.CustomerId; instance.ContactPerson = dto.ContactPerson; instance.ContactPhone = dto.ContactPhone; instance.AddressLine1 = dto.AddressLine1; instance.AddressLine2 = dto.AddressLine2; instance.Country = dto.Country; instance.CountryState = dto.CountryState; instance.City = dto.City; instance.ZipCode = dto.ZipCode; var saveQuery = service.Save(instance); result.AttachResult(instance.RetrieveData <ShipToData>()); result.Merge(saveQuery); } return(result); }
internal TDto RetrieveOrNewShipTo <TDto>(object instanceId, IDataConverter <ShipToData, TDto> converter) where TDto : class { ArgumentValidator.IsNotNull("converter", converter); IShipToService service = UnitOfWork.GetService <IShipToService>(); FacadeUpdateResult <ShipToData> result = new FacadeUpdateResult <ShipToData>(); ShipTo instance = RetrieveOrNew <ShipToData, ShipTo, IShipToService>(result.ValidationResult, instanceId); if (result.IsSuccessful) { return(converter.Convert(instance.RetrieveData <ShipToData>())); } else { return(null); } }