Esempio n. 1
0
        public void Delete(int id)
        {
            IdorModel idor = new IdorModel {
                IdorId = id
            };

            _myContext.Idor.Attach(idor);
            _myContext.Idor.Remove(idor);
            _myContext.SaveChanges();
        }
Esempio n. 2
0
 public IActionResult Post([FromBody] IdorViewModel idor)
 {
     if (ModelState.IsValid)
     {
         string    username = _httpContextAccessor.HttpContext.Request.Cookies.FirstOrDefault(x => x.Key == "User").Value.ToString();
         IdorModel value    = new IdorModel {
             IdorValue = idor.IdorValue, Owner = username
         };
         _myContext.Idor.Add(value);
         _myContext.SaveChanges();
         return(Ok("New value was stored succesfull!"));
     }
     else
     {
         return(BadRequest("Storing the item has failed!"));
     }
 }