Exemple #1
0
        public async Task <FormDto> CreateAsync(FormCreateOrEditDto input)
        {
            var newEntity = await _repository.InsertAsync(new Form(GuidGenerator.Create(),
                                                                   input.Title,
                                                                   input.Description,
                                                                   _currentTenant.Id
                                                                   ));

            return(ObjectMapper.Map <Form, FormDto>(newEntity));
        }
Exemple #2
0
        public async Task <FormDto> UpdateAsync(Guid id, FormCreateOrEditDto body)
        {
            var find = await _repository.GetAsync(id);

            if (find == null)
            {
                throw new EntityNotFoundException(typeof(Form), body.Title);
            }

            find.SetTitle(body.Title);
            find.SetDescription(body.Description);

            return(ObjectMapper.Map <Form, FormDto>(find));
        }