コード例 #1
0
        public async Task <UpdatePersonResponseDto> CreateAsync(UpdatePersonRequestDto request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("PersonService UpdatePersonRequest  is invalid");
            }

            var resp = new UpdatePersonResponseDto();

            try
            {
                var item = mapper.Map <Person.Models.Person>(request.Person);
                await personDao.CreateAsync(item);

                resp.Person = mapper.Map <PersonDto>(await personDao.GetItemAsync(item.Id));
            }
            catch (Exception e) { resp.AddMessage(new Message(e.Message)); };

            personPublisher.PublishEvent(new PersonCreate()
            {
                Id = resp.Person.Id
            });

            return(resp);
        }
コード例 #2
0
        public async Task <UpdatePersonResponseDto> UpdateAsync(UpdatePersonRequestDto request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("PersonService UpdatePersonRequest  is invalid");
            }

            var resp = new UpdatePersonResponseDto();

            try
            {
                var item = mapper.Map <Person.Models.Person>(request.Person);
                await personDao.UpdateAsync(item);
            }
            catch (Exception e) { resp.AddMessage(new Message(e.Message)); }

            return(resp);
        }