Base solution for your next web application
Open Closed

problem with update PbPerson table #3627


User avatar
0
kwanp created

Hi i try to create update function for PbPerson problem is when i update the fields [CreatorUserId] and [TenantId] become null data the data i have change also not update to the DB

Id	CreationTime	CreatorUserId	DeleterUserId	DeletionTime	EmailAddress	IsDeleted	LastModificationTime	LastModifierUserId	Name	Surname	TenantId
53	2017-07-31 22:18:12.1840917	2	2	2017-07-31 22:20:10.8563334	NULL	1	NULL	NULL	a	b	1
54	2017-07-31 22:27:05.3251989	NULL	NULL	NULL	NULL	0	2017-07-31 22:27:05.3261990	NULL	a	a	0
55	2017-07-31 22:30:47.0648198	NULL	NULL	NULL	NULL	0	2017-07-31 22:30:47.0658199	NULL	a	a	0
58	2017-07-31 22:36:52.3516411	NULL	NULL	NULL	NULL	0	2017-07-31 22:36:52.3566414	NULL	a	c	0

i have create class:

[AutoMapTo(typeof(Person))]
    public class CreateOrUpdatePersonInput
    {
        public int? Id { get; set; }

        [Required]
        [MaxLength(Person.MaxNameLength)]
        public string Name { get; set; }

        [Required]
        [MaxLength(Person.MaxSurnameLength)]
        public string Surname { get; set; }

        [EmailAddress]
        [MaxLength(Person.MaxEmailAddressLength)]
        public string EmailAddress { get; set; }
    }

and on the service

public async Task CreatePerson(CreateOrUpdatePersonInput input)//(CreatePersonInput input)
        {
            var person = ObjectMapper.Map<Person>(input);
            await _personRepository.InsertOrUpdateAsync(person);
      }

Thank you


1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @kwanp,

    You must first get person from database and then you need to map your dto to it, then save it.

    Thanks.