Actually you need to do it on the client and server side.
You mean that on the server-side I write the code that will return the meta data for a form (which fields to show and hide). On the client side I use Angular to show/hide.
Originally I thought in addition to writing code on server side to know what field to show and what to hide, I thought I can do the filtering on razor view server side rather than angular.
By the way, what's your first name?
Problem solved.
My entity belongs to a Tenant. I was not supplying TenantId for the entity.
In case someone faces same issue, you just make sure to set TenantId on the new entity.
Regards Bilal
Hi, I am getting the following exception when running Update-Database. any idea why?
PM> Update-Database
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
No pending explicit migrations.
Running Seed method.
System.Runtime.Serialization.SerializationException: Type is not resolved for member 'Abp.AbpException,Abp, Version=1.4.2.0, Culture=neutral, PublicKeyToken=null'.
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)
at System.Data.Entity.Migrations.Design.ToolingFacade.Update(String targetMigration, Boolean force)
at System.Data.Entity.Migrations.UpdateDatabaseCommand.<>c__DisplayClass2.<.ctor>b__0()
at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
Type is not resolved for member 'Abp.AbpException,Abp, Version=1.4.2.0, Culture=neutral, PublicKeyToken=null'.
Thanks :) As long as I don't hit Update-Database should be fine :)
Thank you.
But I meant that one method returns Task<IdentityResult> and the other results Task.
Thanks
On the client side (angular) you mean?
hi,
I am checking the code for Module Zero to follow your best practices in writing new custom code.
I noticed 2 ways of writing Create or Update code. I know both work great, but is there a preference to which one to use?
Thanks
First way:
public virtual async Task<IdentityResult> CreateAsync(TTenant tenant)
{
if (await TenantRepository.FirstOrDefaultAsync(t => t.TenancyName == tenant.TenancyName) != null)
{
return AbpIdentityResult.Failed(string.Format(L("TenancyNameIsAlreadyTaken"), tenant.TenancyName));
}
var validationResult = await ValidateTenantAsync(tenant);
if (!validationResult.Succeeded)
{
return validationResult;
}
await TenantRepository.InsertAsync(tenant);
return IdentityResult.Success;
}
Second way:
[UnitOfWork]
public virtual async Task AddAsync(ApplicationLanguage language)
{
if ((await GetLanguagesAsync(language.TenantId)).Any(l => l.Name == language.Name))
{
throw new AbpException("There is already a language with name = " + language.Name);
}
using (_unitOfWorkManager.Current.SetTenantId(language.TenantId))
{
await _languageRepository.InsertAsync(language);
await _unitOfWorkManager.Current.SaveChangesAsync();
}
}
My problem is, I am storing in cache a class having Id of type object. Then, I am trying to map a non-generic instance to a generic-instance.
I ended up storing the HostEntityBase<T> in cache, this way, when I retrieve data I don't have to map or convert. I am not sure this is the correct way,
Can you please check if this ok or you suggest any enhancement? My only worries is that the HostEntityBase<T> has few methods and I was planning to store pure data in cache that is why I created the CacheItem above.
Thank you :)
public class HostEntityCacheItem<THostEntityBase>
{
public static string CacheStoreName = $"Drc{typeof(THostEntityBase).FullName.ToString()}";
public List<THostEntityBase> Items { get; set; }
public HostEntityCacheItem()
:this(new List<THostEntityBase>())
{
}
public HostEntityCacheItem(List<THostEntityBase> list)
{
Items = new List<THostEntityBase>(list);
}
}
[UnitOfWork]
private async Task<HostEntityCacheItem<THostEntityBase>> GetListFromCacheAsync()
{
return await CacheManager.GetHostEntityCache<THostEntityBase>().GetAsync(GenerateDefaultCacheKeyName(),
async () =>
{
//Get a list from the database
var list = (await GetHostEntityFromDatabaseAsync());
return new HostEntityCacheItem<THostEntityBase>(list);
});
}
Hello, Can you please refer me to the source code in the framework where you implement some business rules? I want to see how to implement that in terms of classes and interfaces, etc.
Thanks Bilal
For example, @L() isn't this somewhere referring to a class in the solution that connects to the Db? I was planning to do something similar.
A separate IVisibilityChecker and VisibilityChecker classes, inject them into the base View Page, then be able to access the IfShown or IfHidden, etc.
Other way around, is in the header of the .cshtml file, I might also create an instance of some class that connects to Db.
Thanks