public static async Task <OdooResult <bool> > UpdateRangeAsync(OdooConfig odooConfig, int userUid, IOdooCreateModel model, long[] ids) { var tableName = model.OdooTableName(); var request = OdooRequestModel.Update(odooConfig, userUid, tableName, ids, model); return(await CallAndDeserializeAsync <bool>(request)); }
public static async Task <OdooResult <long> > CreateAsync(OdooConfig odooConfig, int userUid, OdooDictionaryModel model) { var request = OdooRequestModel.Create(odooConfig, userUid, GetTableName(model), model); var result = await CallAndDeserializeAsync <long[]>(request); return(result.Succeed ? result.ToResult(result.Value.FirstOrDefault()) : OdooResult <long> .FailedResult(result)); }
public static async Task <OdooResult <long> > GetCountAsync <T>(OdooConfig odooConfig, int userUid, OdooQuery query = null) where T : IOdooModel, new() { var tableName = OdooExtensions.GetOdooTableName <T>(); var request = OdooRequestModel.SearchCount(odooConfig, userUid, tableName, query); return(await CallAndDeserializeAsync <long>(request)); }
public async Task Can_get_product_with_selected_language_using_repository_init() { var confing = new OdooConfig(TestConfig.ApiUrl, TestConfig.DbName, TestConfig.UserName, TestConfig.Password, "nl_BE"); var repository = new OdooRepository <ProductProductOdooModel>(confing); var product = await repository.Query() .ById(282) .FirstOrDefaultAsync(); product.Error.Should().BeNull(); product.Value.Should().NotBeNull(); product.Succeed.Should().BeTrue(); product.Value.Name.Should().Contain("Dutch"); var product2 = await repository.Query() .ById(282) .FirstOrDefaultAsync(); product2.Error.Should().BeNull(); product2.Value.Should().NotBeNull(); product2.Succeed.Should().BeTrue(); product2.Value.Name.Should().Contain("Dutch"); var productWithoutLanguage = await repository.Query() .ById(282) .WithContext(new OdooContext()) .FirstOrDefaultAsync(); productWithoutLanguage.Error.Should().BeNull(); productWithoutLanguage.Value.Should().NotBeNull(); productWithoutLanguage.Succeed.Should().BeTrue(); productWithoutLanguage.Value.Name.Should().NotContain("Dutch"); var product3 = await repository.Query() .ById(282) .FirstOrDefaultAsync(); product3.Error.Should().BeNull(); product3.Value.Should().NotBeNull(); product3.Succeed.Should().BeTrue(); product3.Value.Name.Should().Contain("Dutch"); }
public static OdooRequestModel Version(OdooConfig config) { var param = new OdooRequestParams(config.ApiUrlJson, "common", "version"); return(new OdooRequestModel(param)); }
public static OdooRequestModel Login(OdooConfig config) { var param = new OdooRequestParams(config.ApiUrlJson, "common", "login", config.DbName, config.UserName, config.Password); return(new OdooRequestModel(param)); }
public static OdooRequestModel Update(OdooConfig config, int uid, string tableName, long[] ids, object model) { var param = new OdooRequestParams(config.ApiUrlJson, "object", "execute", config.DbName, uid, config.Password, tableName, OdooOperation.Update, ids, model, config.Context); return(new OdooRequestModel(param)); }
public static OdooRequestModel Metadata(OdooConfig config, int uid, string tableName, long[] ids, OdooContext context = null) { var param = new OdooRequestParams(config.ApiUrlJson, "object", "execute_kw", config.DbName, uid, config.Password, tableName, OdooOperation.GetMetadata, new object[] { ids }, MapQuery(context)); return(new OdooRequestModel(param)); }
public OdooRepository(OdooConfig config) { OdooClient = new OdooClient(config); TableName = OdooExtensions.GetOdooTableName <T>(); }
public static async Task <OdooResult <bool> > UpdateRangeAsync(OdooConfig odooConfig, int userUid, OdooDictionaryModel model, long[] ids) { var request = OdooRequestModel.Update(odooConfig, userUid, GetTableName(model), ids, model); return(await CallAndDeserializeAsync <bool>(request)); }
public static async Task <OdooResult <OdooVersion> > GetVersionAsync(OdooConfig odooConfig) { var request = OdooRequestModel.Version(odooConfig); return(await CallAndDeserializeAsync <OdooVersion>(request)); }
public static OdooRequestModel SearchCount(OdooConfig config, int uid, string tableName, OdooQuery query = null, OdooContext context = null) { var param = new OdooRequestParams(config.ApiUrlJson, "object", "execute_kw", config.DbName, uid, config.Password, tableName, OdooOperation.SearchCount, GetRequestFilters(query), MapQuery(context, query)); return(new OdooRequestModel(param)); }
public static async Task <OdooResult <Dictionary <string, OdooPropertyInfo> > > GetModelAsync(OdooConfig odooConfig, int userUid, string tableName) { var request = OdooRequestModel.ModelFields(odooConfig, userUid, tableName); return(await CallAndDeserializeAsync <Dictionary <string, OdooPropertyInfo> >(request)); }
public OdooClient(OdooConfig config) { _config = config; }
public static async Task <OdooResult <int> > LoginAsync(OdooConfig odooConfig) { var request = OdooRequestModel.Login(odooConfig); return(await CallAndDeserializeAsync <int>(request)); }
public static async Task <OdooResult <bool> > DeleteRangeAsync(OdooConfig odooConfig, int userUid, string tableName, long[] ids) { var request = OdooRequestModel.Delete(odooConfig, userUid, tableName, ids); return(await CallAndDeserializeAsync <bool>(request)); }
public static async Task <OdooResult <bool> > DeleteAsync(OdooConfig odooConfig, int userUid, string tableName, long id) { return(await DeleteRangeAsync(odooConfig, userUid, tableName, new[] { id })); }
public static OdooRequestModel ModelFields(OdooConfig config, int uid, string tableName) { var param = new OdooRequestParams(config.ApiUrlJson, "object", "execute", config.DbName, uid, config.Password, tableName, OdooOperation.FieldsGet); return(new OdooRequestModel(param)); }
public static async Task<OdooResult<long>> CreateAsync(OdooConfig odooConfig, int userUid, IOdooCreateModel model, OdooContext context = null) { var request = OdooRequestModel.Create(odooConfig, userUid, model.OdooTableName(), model, context); var result = await CallAndDeserializeAsync<long>(request); return result.Succeed ? result.ToResult(result.Value) : OdooResult<long>.FailedResult(result); }
public static OdooRequestModel Read(OdooConfig config, int uid, string tableName, long[] ids, OdooQuery query = null, OdooContext context = null) { var param = new OdooRequestParams(config.ApiUrlJson, "object", "execute_kw", config.DbName, uid, config.Password, tableName, OdooOperation.Read, ids, MapQuery(context, query)); return(new OdooRequestModel(param)); }
public static async Task<OdooResult<bool>> UpdateAsync(OdooConfig odooConfig, int userUid, IOdooCreateModel model, long id, OdooContext context = null) { return await UpdateRangeAsync(odooConfig, userUid, model, new[] { id }, context); }
public static OdooRequestModel Create(OdooConfig config, int uid, string tableName, object model, OdooContext context = null) { var param = new OdooRequestParams(config.ApiUrlJson, "object", "execute_kw", config.DbName, uid, config.Password, tableName, OdooOperation.Create, new[] { model }, MapQuery(context)); return(new OdooRequestModel(param)); }
public static OdooRequestModel SearchRead(OdooConfig config, int uid, string tableName, OdooQuery query = null) { var param = new OdooRequestParams(config.ApiUrlJson, "object", "execute", config.DbName, uid, config.Password, tableName, OdooOperation.SearchRead, query?.GetRequestFilters(), query?.GetRequestFields(), query?.Offset, query?.Limit, query?.Order); return(new OdooRequestModel(param)); }
public static async Task<OdooResult<T[]>> GetAsync<T>(OdooConfig odooConfig, int userUid, OdooQuery query = null, OdooContext context = null) where T : IOdooModel, new() { var tableName = OdooExtensions.GetOdooTableName<T>(); var request = OdooRequestModel.SearchRead(odooConfig, userUid, tableName, query, context); return await CallAndDeserializeAsync<T[]>(request); }
public static async Task <OdooResult <bool> > UpdateAsync(OdooConfig odooConfig, int userUid, OdooDictionaryModel model, long id) { return(await UpdateRangeAsync(odooConfig, userUid, model, new[] { id })); }