We have an object named 'trading company', this object contains a list of 'trading company dynamic fields'
public class TradingCompany : FullAuditedEntity<Guid>
{
///other props
/// <summary>
/// DynamicFields.
/// </summary>
public IEnumerable<TradingCompanyDynamicField> Dynamicfields { get; set; }
}
public class TradingCompanyDynamicField: Entity<Guid>
{
/// <summary>
/// DynamicField.
/// </summary>
public string DynamicField { get; set; }
}
In the trading company appservice we have to update all the dynamic fields manually
public virtual async Task<TradingCompanyDto> UpdateAsync(Guid id, TradingCompanyUpdateDto input)
{
var tradingCompany = _tradingCompanyRepository.AsQueryable()
.Where(d => d.Id == id)
.Include(d => d.Dynamicfields)
.FirstOrDefault();
var currentList = tradingCompany.Dynamicfields;
ObjectMapper.Map(input, tradingCompany);
tradingCompany = await _tradingCompanyRepository.UpdateAsync(tradingCompany);
// Delete in current not in input.
var toDelete = currentList.Where(c => currentList.Select(d => d.Id).ToList().IndexOf(c.Id) == -1);
await _tradingCompanyDynamicFieldRepository.DeleteManyAsync(toDelete);
// Add in input, not in current.
var toAdd = currentList.Where(c => currentList.Select(d => d.Id).ToList().IndexOf(c.Id) == -1);
await _tradingCompanyDynamicFieldRepository.InsertManyAsync(
toAdd.Select(a => new TradingCompanyDynamicField
{
DynamicField = a.DynamicField,
TradingCompanyId = tradingCompany.Id
}));
// Update others.
var toUpdate = currentList.Where(c => currentList.Select(d => d.Id).ToList().IndexOf(c.Id) > -1);
await _tradingCompanyDynamicFieldRepository.UpdateManyAsync(
toUpdate.Select(u => ObjectMapper.Map(currentList.FirstOrDefault(i => i.Id == u.Id), u))
);
return ObjectMapper.Map<TradingCompany, TradingCompanyDto>(tradingCompany);
}
What we want would be something like this, this would also update all dynamicfields automatically:
public virtual async Task<TradingCompanyDto> UpdateAsync(Guid id, TradingCompanyUpdateDto input)
{
var tradingCompany = _tradingCompanyRepository.AsQueryable()
.Where(d => d.Id == id)
.Include(d => d.Dynamicfields)
.FirstOrDefault();
ObjectMapper.Map(input, tradingCompany);
tradingCompany = await _tradingCompanyRepository.UpdateAsync(tradingCompany);
return ObjectMapper.Map<TradingCompany, TradingCompanyDto>(tradingCompany);
}
Executing the desired code results in swagger to the expected data. For example, update a trading company having 3 dynamic fields to one having only 2, returns an object only containing the 2 dynamic fields. But when we get by id/list or check in the database, we'll see all dynamic fields have the property 'isdeleted' set to true.
How can we achieve this?
Kind regards Lotte
We'd like to have different swagger files for sections of our code. I've added following items in the hostmodule to add a second swagger definition:
options.SwaggerDoc("v1-backoffice", new OpenApiInfo { Title = "DLV_TC_Platform API Backoffice", Version = "v1" });
options.SwaggerDoc("v1-frontend", new OpenApiInfo { Title = "DLV_TC_Platform API Frontend", Version = "v1" });
options.SwaggerEndpoint("/swagger/v1-backoffice/swagger.json", "DLV_TC_Platform API BackOffice");
options.SwaggerEndpoint("/swagger/v1-frontend/swagger.json", "DLV_TC_Platform API Frontend");
With this setup you get two versions but they are the same.
How can I now indicate which services may appear on which swagger? Preferably with a convention-like method, so it can be setup once and then 'forgotten'.
Kind regards Lotte
Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.
Hello
I've got a question.. Abp Suite offers a nice solution to upgrade all packages etc to a new version, but how should we manage the interface (angular side?) If a new UI would be available, how could we implement it in our application withouth having to remake it all?
Kind regards Lotte