/// <summary> /// Update or create a single BOSRecord or a list of BOSRecords, depending on whether the BOSRecord or BOSRecords property has got a value set. /// If the BOSRecord property is set the BOSRecord will be created or updated and the BOSRecords property will be ignored. /// To create or update more than one BOSRecord, assign a list to the BOSRecords property and make sure BOSRecord is set to nothing/null. /// </summary> /// <param name="request">The request containing the BOSRecord or BOSRecords that needs to be created or updated</param> /// <returns>depending on the values supplied, the updated BOSRecord or BOSRecords will be returned.</returns> public virtual BOSEntitiesResponse Any(StoreBOSEntities request) { BOSEntitiesResponse response = new BOSEntitiesResponse(); IGenericEntityRepositoryBase <BOSEntity, IDataContextBOS> _repository = _DataRepositoryFactory.GetDataRepository <IGenericEntityRepositoryBase <BOSEntity, IDataContextBOS> >(); response.BOSEntities = _repository.CreateUpdateList(request.BOSEntities.ConvertAllTo <BOSEntity>().ToList(), CurrentSessionUsername).ConvertAllTo <BOSEntityDto>().ToList(); return(response); }
/// <summary> /// Find a BOSRecord by specifying values for the properties available in the request. /// Date values: Start date will go from date forward, end date will be from end date back, and if both has values, /// it will be used as from (between) start to end /// </summary> /// <param name="request">The request used for building the find parameters</param> /// <returns>If LoadLazy was true, then a list of JarsBOSRecordBase items, otherwise a list of fully loaded JarsBOSRecords</returns> public virtual BOSEntitiesResponse Any(FindBOSEntities request) { BOSEntitiesResponse response = new BOSEntitiesResponse(); if (request != null) { Expression <Func <BOSEntity, bool> > query = LinqExpressionBuilder.True <BOSEntity>(); //Id if (request.ResourceId != null) { query = query.And(a => a.ResourceId == int.Parse(request.ResourceId)); } //StartDateTime if (request.StartDate.HasValue && request.StartDate != DateTime.MinValue) { query = query.And(a => a.StartDate.Date >= request.StartDate.Value.Date); } //EndDateTime (unlike the mobile version we dont set the end date = start date if the end date is empty) if (request.EndDate.HasValue && request.EndDate != DateTime.MinValue) { query = query.And(a => a.EndDate.Date <= request.EndDate.Value.Date); } //statuses if (!request.Statuses.IsNullOrEmpty()) { //if the status value contains a , then split it, otherwise just use as is if (request.Statuses.Contains(',')) { string[] arrStatus = request.Statuses.Split(new[] { ',' }); query = query.And(a => arrStatus.Contains(a.ProgressStatus)); } else { query = query.And(a => a.ProgressStatus == request.Statuses); } } IGenericEntityRepositoryBase <BOSEntity, IDataContextBOS> _repository = _DataRepositoryFactory.GetDataRepository <IGenericEntityRepositoryBase <BOSEntity, IDataContextBOS> >(); response.BOSEntities = _repository.Where(query, true).ConvertAllTo <BOSEntityDto>().ToList(); } return(response); }