Exemplo n.º 1
0
        //TODO : VIEW MODEL
        public IActionResult Create([FromBody] CmsViewModel cms)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Cms _newCms = new Cms {
                Titulo = cms.Titulo, Avatar = cms.Avatar, QtdFields = cms.QtdFields, WorkItemTypeId = cms.WorkItemTypeId, FieldsCreated = cms.FieldsCreated
            };

            _cmsRepository.Add(_newCms);
            _cmsRepository.Commit();
            //TODO : VIEW MODEL
            //cms = Mapper.Map<Cms, CmsViewModel>(_newCms);

            CreatedAtRouteResult result = CreatedAtRoute("GetCmsies", new { controller = "Cmsies", id = _newCms.Id }, cms);

            return(result);
        }