public IHttpActionResult PutJoc(int id, Joc joc) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != joc.Id) { return(BadRequest()); } db.Entry(joc).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!JocExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public GameSession(string jucator1, string jucator2, string jucatorCurent, int runda, Joc jc) { Jucator1 = jucator1 ?? throw new ArgumentNullException(nameof(jucator1)); Jucator2 = jucator2 ?? throw new ArgumentNullException(nameof(jucator2)); JucatorCurent = jucatorCurent ?? throw new ArgumentNullException(nameof(jucatorCurent)); Runda = runda; JocDb = jc; }
public void Add(Joc j) { using (var context = new ExamenMppEntities()) { context.Jocs.Add(j); context.SaveChanges(); } }
public void Update(Joc m) { using (var context = new ExamenMppEntities()) { var oldEntity = Find(m.Id); oldEntity.PozitieJucator1 = m.PozitieJucator1; oldEntity.PozitieJucator2 = m.PozitieJucator2; context.SaveChanges(); } }
public IHttpActionResult GetJoc(int id) { Joc joc = db.Jocs.Find(id); if (joc == null) { return(NotFound()); } return(Ok(joc)); }
public IHttpActionResult PostJoc(Joc joc) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Jocs.Add(joc); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = joc.Id }, joc)); }
public IHttpActionResult DeleteJoc(int id) { Joc joc = db.Jocs.Find(id); if (joc == null) { return(NotFound()); } db.Jocs.Remove(joc); db.SaveChanges(); return(Ok(joc)); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Joc = await _context.Joc.FirstOrDefaultAsync(m => m.ID == id); if (Joc == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Joc = await _context.Joc.FindAsync(id); if (Joc != null) { _context.Joc.Remove(Joc); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public void Update(Joc c) { _repository.Update(c); }
public void Add(Joc c) { _repository.Add(c); }