Ejemplo n.º 1
0
        public async Task <ActionResult> Store([FromBody] TermViewModel model)
        {
            await ValidateRequestAsync(model);

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var term = model.MapEntity(_mapper, CurrentUserId);

            term = await _termsService.CreateAsync(term);

            return(Ok(term.Id));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Update(int id, [FromBody] TermViewModel model)
        {
            var existingEntity = _termsService.GetById(id);

            if (existingEntity == null)
            {
                return(NotFound());
            }

            await ValidateRequestAsync(model);

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var term = model.MapEntity(_mapper, CurrentUserId);

            await _termsService.UpdateAsync(existingEntity, term);

            return(Ok());
        }