// PUT: api/DodajPin/5 public void Put([FromBody] ClientAuth clijentAuth) { using (var ctx = new foiknjiznicaEntities()) { var upit = db.Clanovi_Auth_Protocol.Where(x => x.ClanoviId == clijentAuth.ClanoviId).SingleOrDefault(); if (upit != null) { upit.ClanoviId = clijentAuth.ClanoviId; upit.Auth_ProtocolId = clijentAuth.Auth_ProtocolId; upit.podaci = clijentAuth.podaci; //upit.odabrano = clijentAuth.odabrano; } else { ctx.Clanovi_Auth_Protocol.Add(new Clanovi_Auth_Protocol() { ClanoviId = clijentAuth.ClanoviId, Auth_ProtocolId = clijentAuth.Auth_ProtocolId, podaci = clijentAuth.podaci, //odabrano = clijentAuth.odabrano }); } ctx.SaveChanges(); } }
// POST: api/DodajAuthProtocol public void Post([FromBody] ClientAuth clijentAuth) { using (var ctx = new foiknjiznicaEntities()) { var upit = ctx.Clanovi_Auth_Protocol.Where(x => x.ClanoviId == clijentAuth.ClanoviId).FirstOrDefault(); if (upit != null) { ctx.Entry(upit).State = System.Data.Entity.EntityState.Deleted; } ctx.Clanovi_Auth_Protocol.Add(new Clanovi_Auth_Protocol { ClanoviId = clijentAuth.ClanoviId, Auth_ProtocolId = clijentAuth.Auth_ProtocolId, podaci = clijentAuth.podaci, //odabrano = clijentAuth.odabrano }); ctx.SaveChanges(); } }