public HttpResponseMessage Post([FromBody] telefon tel) { var telefon = TelefonsRepository.InsertTelefon(tel); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, telefon); return(response); }
public HttpResponseMessage Put(int id, [FromBody] telefon val) { var contacte = TelefonsRepository.UpdateTelefon(id, val); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, contacte); return(response); }
public static void DeleteTelefon(int id) { telefon c = RepositoryGlobal.dataContext.telefons.Where(x => x.telId == id).SingleOrDefault(); if (c != null) { RepositoryGlobal.dataContext.telefons.Remove(c); RepositoryGlobal.dataContext.SaveChanges(); } }
public static telefon InsertTelefon(telefon tel) { try { RepositoryGlobal.dataContext.telefons.Add(tel); RepositoryGlobal.dataContext.SaveChanges(); return(GetTelefon(tel.telId)); } catch (Exception e) { return(null); } }
public static telefon UpdateTelefon(int id, telefon t) { try { telefon t0 = RepositoryGlobal.dataContext.telefons.Where(x => x.telId == id).SingleOrDefault(); if (t.telefon1 != null) { t0.telefon1 = t.telefon1; } if (t.tipus != null) { t0.tipus = t.tipus; } RepositoryGlobal.dataContext.SaveChanges(); return(GetTelefon(id)); } catch (Exception e) { return(null); } }
public static telefon GetTelefon(int id) { telefon t = RepositoryGlobal.dataContext.telefons.Where(x => x.telId == id).SingleOrDefault(); return(t); }