Example #1
0
        public async Task <EventDto> UpdateAsync(int id, EventUpsertRequest req)
        {
            Event entity = _mapper.Map <Event>(req);

            entity.Id = id;

            await _eventRepo.UpdateAsync(entity, id);

            entity = await _eventRepo.GetAsync(id);

            await _unit.SaveAsync();

            var dto = _mapper.Map <EventDto>(entity);

            return(dto);
        }
Example #2
0
        public async Task <EventDto> InsertAsync(EventUpsertRequest req)
        {
            var entity = _mapper.Map <Event>(req);

            int authorId = await _authService.GetCurrentUserIdAsync();

            entity.AuthorId = authorId;

            await _eventRepo.InsertAsync(entity);

            await _unit.SaveAsync();

            var dto = _mapper.Map <EventDto>(entity);

            return(dto);
        }