コード例 #1
0
        public HttpResponseMessage Post([FromBody] email em)
        {
            var email = EmailsRepository.InsertEmail(em);
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, email);

            return(response);
        }
コード例 #2
0
        public HttpResponseMessage Put(int id, [FromBody] email val)
        {
            var contacte = EmailsRepository.UpdateEmail(id, val);
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, contacte);

            return(response);
        }
コード例 #3
0
        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();
            }
        }
コード例 #4
0
 public static email InsertEmail(email em)
 {
     try
     {
         RepositoryGlobal.dataContext.emails.Add(em);
         RepositoryGlobal.dataContext.SaveChanges();
         return(GetEmail(em.emailId));
     }
     catch (Exception e)
     {
         return(null);
     }
 }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
        public static email GetEmail(int id)
        {
            email t = RepositoryGlobal.dataContext.emails.Where(x => x.emailId == id).SingleOrDefault();

            return(t);
        }