예제 #1
0
        public HttpResponseMessage Post([FromBody] telefon tel)
        {
            var telefon = TelefonsRepository.InsertTelefon(tel);
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, telefon);

            return(response);
        }
예제 #2
0
        public HttpResponseMessage Put(int id, [FromBody] telefon val)
        {
            var contacte = TelefonsRepository.UpdateTelefon(id, val);
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, contacte);

            return(response);
        }
예제 #3
0
        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();
            }
        }
예제 #4
0
 public static telefon InsertTelefon(telefon tel)
 {
     try
     {
         RepositoryGlobal.dataContext.telefons.Add(tel);
         RepositoryGlobal.dataContext.SaveChanges();
         return(GetTelefon(tel.telId));
     }
     catch (Exception e)
     {
         return(null);
     }
 }
예제 #5
0
        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);
            }
        }
예제 #6
0
        public static telefon GetTelefon(int id)
        {
            telefon t = RepositoryGlobal.dataContext.telefons.Where(x => x.telId == id).SingleOrDefault();

            return(t);
        }