Beispiel #1
0
        public async Task <ActionResult> Store([FromBody] FeatureViewModel model)
        {
            ValidateRequest(model);
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            model.Order = model.Active ? 0 : -1;

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

            feature = await _manualsService.CreateFeatureAsync(feature);

            return(Ok(feature.Id));
        }
Beispiel #2
0
        public async Task <ActionResult> Update(int id, [FromBody] FeatureViewModel model)
        {
            var existingEntity = await _manualsService.GetFeatureByIdAsync(id);

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

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

            model.Order = model.Active ? 0 : -1;
            var feature = model.MapEntity(_mapper, CurrentUserId);

            await _manualsService.UpdateFeatureAsync(existingEntity, feature);

            return(Ok());
        }