Hi oguzhanagir
The Create method is :
[AbpAuthorize(AppPermissions.Pages_Persons_Create)] protected virtual async Task <int> Create(CreateOrEditPersonDto input) { var person = ObjectMapper.Map<Person>(input);
`
if (AbpSession.TenantId != null)
{
person.TenantId = (int?)AbpSession.TenantId;
}
person.Color = GenerateRandomColor();
await _personRepository.InsertAsync(person);
await CurrentUnitOfWork.SaveChangesAsync();
return person.Id ;
}`
and JS :
` _personsService .createOrEdit(person) .done(function (result) {
console.log("PersonId :" + result);
abp.notify.info(app.localize('SavedSuccessfully'));
abp.event.trigger('app.createOrEditPersonModalSaved');
if (typeof successCallback === 'function') {
successCallback();
}
})`
Hi oguzhanagir,
Sorry i'm not able ro retrieve saved data in my view when Create Mode; there might be an example in the project ? I am not used to working in service mode but directly with a controller and in ASP MVC 5 version;
thks for help Bernard
Hi, Do I have to return the result in Json to be able to read it on Jquery side? Because id is empty and other fields are filled
Hi oguzhanagir,
It works fine thks ! Is there any possibility to change View Sate from Create to Edit so when saving the param Id of person is sended to the server in personservice
And please additional infirmation :
what is this method for :
abp.event.trigger('app.createOrEditPersonModalSaved');
Hi,
I tried this but the id is null
protected virtual async Task <Person> Create(CreateOrEditPersonDto input) { var person = ObjectMapper.Map<Person>(input);
if (AbpSession.TenantId != null)
{
person.TenantId = (int?)AbpSession.TenantId;
}
person.Color = GenerateRandomColor();
await _personRepository.InsertAsync(person);
return person;
} the purpose is to be able to save an entity without having to close the view and to have the data returned in the form
`
Hi oguzhanagir,
I found the solution :
public ICollection<Tache> Taches { get; set; } was in the wrong class : Should be in CreateOrEditPersonDto anf not in GetPersonForEditOutput !
Thks anyway for your precious help
bernard
Hi,
I'm moving forward with my problem, I changed the initial request :
var person = await _personRepository.FirstOrDefaultAsync(input.Id);
by
var person = await _personRepository.GetAllIncluding(x => x.Taches).FirstOrDefaultAsync(x => x.Id == input.Id);
this gives me an include collection of taches :
But the mapping doesn't work :
For reminding GetPersonForEditOutput class looks like :
` public class GetPersonForEditOutput { public CreateOrEditPersonDto Person { get; set; }
public virtual Guid? PictureId { get; set; }
public string TacheIntitule { get; set; }
public string PersonIntitule { get; set; }
public string EntityFullName { get; set; }
public List<string> AllEntities { get; set; }
public List<DynamicPropertyDto> DynamicProperties { get; set; }
public ICollection<TacheDto> Taches { get; set; }
}`
and ( i does not add public ICollection<TacheDto> Taches { get; set; } in it)
` public class CreateOrEditPersonDto : EntityDto<int?> {
[StringLength(PersonConsts.MaxIntituleLength, MinimumLength = PersonConsts.MinIntituleLength)]
public string Intitule { get; set; }
[StringLength(PersonConsts.MaxAdresse1Length, MinimumLength = PersonConsts.MinAdresse1Length)]
public string Adresse1 { get; set; }
[StringLength(PersonConsts.MaxAdresse2Length, MinimumLength = PersonConsts.MinAdresse2Length)]
public string Adresse2 { get; set; }
[StringLength(PersonConsts.MaxAdresse3Length, MinimumLength = PersonConsts.MinAdresse3Length)]
public string Adresse3 { get; set; }
[StringLength(PersonConsts.MaxCodePostalLength, MinimumLength = PersonConsts.MinCodePostalLength)]
public string CodePostal { get; set; }
[StringLength(PersonConsts.MaxVilleLength, MinimumLength = PersonConsts.MinVilleLength)]
public string Ville { get; set; }
[StringLength(PersonConsts.MaxEmailLength, MinimumLength = PersonConsts.MinEmailLength)]
public string Email { get; set; }
[StringLength(PersonConsts.MaxTelLength, MinimumLength = PersonConsts.MinTelLength)]
public string Telephone { get; set; }
[StringLength(PersonConsts.MaxNotesLength, MinimumLength = PersonConsts.MinNotesLength)]
public string Notes { get; set; }
public TypePerson TypePerson { get; set; }
[StringLength(PersonConsts.MaxCodeClientLength, MinimumLength = PersonConsts.MinCodeClientLength)]
public string CodeClient { get; set; }
[StringLength(PersonConsts.MaxCodeComptableLength, MinimumLength = PersonConsts.MinCodeComptableLength)]
public string CodeComptable { get; set; }
public Guid? PictureId { get; set; }
public bool IsActive { get; set; }
[StringLength(PersonConsts.MaxNomJeuneFilleLength, MinimumLength = PersonConsts.MinNomJeuneFilleLength)]
public string NomJeuneFille { get; set; }
public DateTime? DateNaissance { get; set; }
public string Nationalite { get; set; }
[StringLength(PersonConsts.MaxNumSecuLength, MinimumLength = PersonConsts.MinNumSecuLength)]
public string NumSecu { get; set; }
[StringLength(PersonConsts.MaxPrenomLength, MinimumLength = PersonConsts.MinPrenomLength)]
public string Prenom { get; set; }
[StringLength(PersonConsts.MaxNomLength, MinimumLength = PersonConsts.MinNomLength)]
public string Nom { get; set; }
[StringLength(PersonConsts.MaxFonctionLength, MinimumLength = PersonConsts.MinFonctionLength)]
public string Fonction { get; set; }
public string CodeNaf { get; set; }
public string Siret { get; set; }
[StringLength(PersonConsts.MaxFormeJuridiqueLength, MinimumLength = PersonConsts.MinFormeJuridiqueLength)]
public string FormeJuridique { get; set; }
[Range(PersonConsts.MinEmployesValue, PersonConsts.MaxEmployesValue)]
public int Employes { get; set; }
public decimal CA { get; set; }
public string Adeli { get; set; }
public string RPPS { get; set; }
public ListSource Source { get; set; }
public ListeProfilMorale ProfilMorale { get; set; }
public ListeProfilPhysique ProfilPhysique { get; set; }
public ListeCivilite Civilite { get; set; }
public ListeProfilIntervenant ProfilIntervenant { get; set; }
public TypeStagiaire TypeStagiaire { get; set; }
public ListeStatutPerson Statut { get; set; }
public int? ParentId { get; set; }`
and Person class entity :
[Table("Persons")] public class Person : Entity, IMayHaveTenant,ISoftDelete { ............. public ICollection<Tache> Taches { get; set; }
}
How can I display it in razor view