public IHttpActionResult Putt_user_profile(string id, t_user_profile t_user_profile)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != t_user_profile.t_user_Id)
            {
                return(BadRequest());
            }
            t_user_profile.t_user_UpdateDt = DateTime.Now;
            db.Entry(t_user_profile).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!t_user_profileExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PutEmployee(int id, Employee employee)
        {
            //if (!ModelState.IsValid)
            //{
            //    return BadRequest(ModelState);
            //}

            if (id != employee.EmployeeId)
            {
                return(BadRequest());
            }

            db.Entry(employee).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EmployeeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
 public void Editing_Update([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")] IEnumerable <Emp> emp)
 {
     foreach (var item in emp)
     {
         Employee em = new Employee();
         em.Id              = item.Id;
         em.Name            = item.Name;
         em.Address         = item.Address;
         db.Entry(em).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
Beispiel #4
0
        // POST: api/Contato
        public HttpResponseMessage post([FromBody] Contato contato)
        {
            int resp = 0;
            HttpResponseMessage msg = null;

            try {
                using (TESTEntities entities = new TESTEntities()) {
                    entities.Entry(contato).State = (System.Data.Entity.EntityState)EntityState.Added;
                    resp = entities.SaveChanges();
                    msg  = Request.CreateResponse(HttpStatusCode.OK, resp);
                }
            } catch (Exception ex) {
                msg = Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex);
            }
            return(msg);
        }
        public static void Update(int id, string nombres, string apellidos, string direccion)
        {
            Cliente cliente = new Cliente();

            if (nombres == "" || apellidos == "" || direccion == "")
            {
                nombres   = null;
                apellidos = null;
                direccion = null;
            }
            using (TESTEntities db = new TESTEntities())
            {
                cliente = db.Cliente.Find(id);


                cliente.Nombres   = nombres;
                cliente.Apellidos = apellidos;
                cliente.Direccion = direccion;

                db.Entry(cliente).State = EntityState.Modified;
                db.SaveChanges();
            }
        }