public HttpResponseMessage Post([FromBody] email em) { var email = EmailsRepository.InsertEmail(em); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, email); return(response); }
public HttpResponseMessage Put(int id, [FromBody] email val) { var contacte = EmailsRepository.UpdateEmail(id, val); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, contacte); return(response); }
public static void DeleteEmail(int id) { email c = RepositoryGlobal.dataContext.emails.Where(x => x.emailId == id).SingleOrDefault(); if (c != null) { RepositoryGlobal.dataContext.emails.Remove(c); RepositoryGlobal.dataContext.SaveChanges(); } }
public static email InsertEmail(email em) { try { RepositoryGlobal.dataContext.emails.Add(em); RepositoryGlobal.dataContext.SaveChanges(); return(GetEmail(em.emailId)); } catch (Exception e) { return(null); } }
public static email UpdateEmail(int id, email t) { try { email t0 = RepositoryGlobal.dataContext.emails.Where(x => x.emailId == id).SingleOrDefault(); if (t.email1 != null) { t0.email1 = t.email1; } if (t.tipus != null) { t0.tipus = t.tipus; } RepositoryGlobal.dataContext.SaveChanges(); return(GetEmail(id)); } catch (Exception e) { return(null); } }
public static email GetEmail(int id) { email t = RepositoryGlobal.dataContext.emails.Where(x => x.emailId == id).SingleOrDefault(); return(t); }