public async Task <ActionResult <OrgOdb> > AddOrgOdb(OrgOdb model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (ValidateModel(model, true)) { _context.Entry(model.clanOrgOdbora1).State = EntityState.Unchanged; _context.Entry(model.clanOrgOdbora2).State = EntityState.Unchanged; _context.Entry(model.clanOrgOdbora3).State = EntityState.Unchanged; _context.Entry(model.selektor).State = EntityState.Unchanged; _context.OrgOdbori.Add(model); await _context.SaveChangesAsync(); return(CreatedAtAction("GetOrgOdb", new { id = model.id }, model)); } else { return(BadRequest()); } }
public async Task <ActionResult <OrgOdb> > DeletOrgOdb(int id) { OrgOdb model = await _context.OrgOdbori .FirstOrDefaultAsync(i => i.id == id); if (model == null) { return(NotFound()); } _context.Entry(model).State = EntityState.Deleted; await _context.SaveChangesAsync(); return(Ok()); }
public async Task <ActionResult <OrgOdb> > GetOrgOdb(int id) { OrgOdb model = await _context.OrgOdbori .Include(x => x.clanOrgOdbora1) .Include(x => x.clanOrgOdbora2) .Include(x => x.clanOrgOdbora3) .Include(x => x.selektor) .Include(x => x.pozorista) //.Include(x => x.izabrani) .FirstOrDefaultAsync(i => i.id == id); if (model == null) { return(NotFound()); } return(model); }
public async Task <ActionResult <OrgOdb> > UpdateOrgOdb(OrgOdb model) { _context.Entry(model.clanOrgOdbora1).State = EntityState.Unchanged; _context.Entry(model.clanOrgOdbora2).State = EntityState.Unchanged; _context.Entry(model.clanOrgOdbora3).State = EntityState.Unchanged; _context.Entry(model.selektor).State = EntityState.Unchanged; //foreach (var izabran in model.izabrani) //{ // _context.Entry(izabran).State = EntityState.Unchanged; //} foreach (var pozoriste in model.pozorista) { _context.Entry(pozoriste).State = EntityState.Modified; } _context.Entry(model).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ModelExists(model.id)) { return(NotFound()); } else { throw; } } return(model); }
public async Task <IActionResult> Check(IdChecker idChecker) { if (idChecker.type == 1) { ClanOrgOdb model = await _context.ClanOrgOdbora .FirstOrDefaultAsync(i => i.id == idChecker.idChecker); if (model == null) { return(Ok()); } } if (idChecker.type == 2) { Festival model = await _context.Festivali .FirstOrDefaultAsync(i => i.id == idChecker.idChecker); if (model == null) { return(Ok()); } } if (idChecker.type == 3) { Forma model = await _context.Forme .FirstOrDefaultAsync(i => i.id == idChecker.idChecker); if (model == null) { return(Ok()); } } if (idChecker.type == 4) { Glumac model = await _context.Glumci .FirstOrDefaultAsync(i => i.id == idChecker.idChecker); if (model == null) { return(Ok()); } } if (idChecker.type == 5) { Nagrada model = await _context.Nagrade .FirstOrDefaultAsync(i => i.id == idChecker.idChecker); if (model == null) { return(Ok()); } } if (idChecker.type == 6) { OrgOdb model = await _context.OrgOdbori .FirstOrDefaultAsync(i => i.id == idChecker.idChecker); if (model == null) { return(Ok()); } } if (idChecker.type == 7) { Pozoriste model = await _context.Pozorista .FirstOrDefaultAsync(i => i.id == idChecker.idChecker); if (model == null) { return(Ok()); } } if (idChecker.type == 8) { Predstava model = await _context.Predstave .FirstOrDefaultAsync(i => i.id == idChecker.idChecker); if (model == null) { return(Ok()); } } if (idChecker.type == 9) { PropDeoFest model = await _context.PropDeoFesta .FirstOrDefaultAsync(i => i.id == idChecker.idChecker); if (model == null) { return(Ok()); } } if (idChecker.type == 10) { Radnik model = await _context.Radnici .FirstOrDefaultAsync(i => i.id == idChecker.idChecker); if (model == null) { return(Ok()); } } if (idChecker.type == 11) { Reditelj model = await _context.Reditelji .FirstOrDefaultAsync(i => i.id == idChecker.idChecker); if (model == null) { return(Ok()); } } if (idChecker.type == 12) { Sala model = await _context.Sale .FirstOrDefaultAsync(i => i.id == idChecker.idChecker); if (model == null) { return(Ok()); } } if (idChecker.type == 13) { Selektor model = await _context.Selektori .FirstOrDefaultAsync(i => i.id == idChecker.idChecker); if (model == null) { return(Ok()); } } if (idChecker.type == 14) { Ugovor model = await _context.Ugovori .FirstOrDefaultAsync(i => i.id == idChecker.idChecker); if (model == null) { return(Ok()); } } return(BadRequest()); }
private bool ValidateModel(OrgOdb model, bool isPost) { return(true); }