Example #1
0
        public IActionResult Put(int?id, [FromBody] Concant concant)
        {
            if (!id.HasValue)
            {
                return(BadRequest());
            }
            if (!ModelState.IsValid || concant == null)
            {
                return(BadRequest());
            }

            var oldConcant = _concantRepository.Where(s => s.ConcantId.Equals(id)).SingleOrDefault();

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

            concant.ConcantId = oldConcant.ConcantId;
            if (_concantRepository.Update(concant))
            {
                return(Ok(concant));
            }
            return(BadRequest());
        }
Example #2
0
        public IActionResult Post([FromBody] Concant concant)
        {
            if (!ModelState.IsValid || concant == null)
            {
                return(BadRequest());
            }

            if (_concantRepository.Add(concant))
            {
                return(Ok(concant));
            }

            return(BadRequest());
        }