예제 #1
0
        public IActionResult Post([FromBody] KinShip item)
        {
            //caso nao grave
            if (ModelState.IsValid)
            {
                this.repository.Create(item);
                return(Ok(item));
            }
            else
            {
                //ARRAY STRINGS ERROS
                var errors = new List <string>();
                foreach (var state in ModelState)
                {
                    foreach (var error in state.Value.Errors)
                    {
                        errors.Add(error.ErrorMessage);
                    }
                }

                return(BadRequest(new {
                    code = 401,
                    message = errors
                }));
            }
        }
 public void Update(KinShip ks)
 {
     dataContext.Entry(ks).State = EntityState.Modified;
     dataContext.SaveChanges();
 }
 public void Create(KinShip ks)
 {
     dataContext.Entry(ks).State = EntityState.Added;
     dataContext.SaveChanges();
 }
예제 #4
0
 public IActionResult Put([FromBody] KinShip item)
 {
     this.repository.Update(item);
     return(Ok(item));
 }