/// <summary> /// Find deposit corresponding sales receipt or return null. /// </summary> /// <param name="deposits">collection of deposit.</param> /// <param name="salesReceipt">entity Sales Receipt.</param> /// <returns>found Deposit or null.</returns> private static Deposit FindDeposit(IEnumerable <Deposit> deposits, IntuitEntity salesReceipt) { return(deposits.Where(deposit => deposit.Line != null) .SelectMany(deposit => deposit.Line, (deposit, line) => new { deposit, line }) .Where(t => t.line.LinkedTxn != null) .Select(t => new { t, any = t.line.LinkedTxn.Any(linkedTxn => linkedTxn.TxnId == salesReceipt.Id) }) .Where(t => t.any) .Select(t => t.t.deposit).FirstOrDefault()); }
/// <summary> /// Validate if IntuitEntity was converted successfully /// </summary> /// <param name="intuitEntity"></param> /// <param name="serviceContext"></param> internal static void ValidateIntuitEntity(IntuitEntity intuitEntity, ServiceContext serviceContext) { if (intuitEntity == null) { IdsException exception = new IdsException(Resources.EntityConversionFailedMessage); serviceContext.IppConfiguration.Logger.CustomLogger.Log(Diagnostics.TraceLevel.Error, string.Format(CultureInfo.InvariantCulture, Resources.ExceptionGeneratedMessage, exception.ToString())); IdsExceptionManager.HandleException(exception); } }
internal static T Add <T>(ServiceContext context, T entity) where T : IEntity { //Initializing the Dataservice object with ServiceContext DataService.DataService service = new DataService.DataService(context); //Adding the Bill using Dataservice object T added = service.Add <T>(entity); //get IntuitEntity from entity if (added.GetType().IsSubclassOf(typeof(IntuitEntity))) { IntuitEntity addedEntity = (IntuitEntity)(object)added; //Checking id of added Bill is not Null. If it is Null, Bill is not added properly Assert.IsNotNull(addedEntity.Id); } return(added); }