示例#1
0
        public JSONCollection<TBL_CARGO> Create(string NOMBRE_CARGO)
        {
            JSONCollection<TBL_CARGO> objJSON = new JSONCollection<TBL_CARGO>();
            try
            {
                TBL_CARGO nuevo = new TBL_CARGO()
                {
                    NOMBRE_CARGO = NOMBRE_CARGO
                };
                bd.TBL_CARGO.InsertOnSubmit(nuevo);
                bd.SubmitChanges();

                objJSON.items = nuevo;
                objJSON.totalCount = bd.TBL_CARGO.Count();
                objJSON.success = true;
            }
            catch (Exception e)
            {
                objJSON.success = false;
            }
            return objJSON;
        }
示例#2
0
 public JSONCollection<TBL_CARGO> Update(string id, TBL_CARGO nuevo)
 {
     JSONCollection<TBL_CARGO> objJSON = new JSONCollection<TBL_CARGO>();
     try
     {
         var objeto = (from variable in bd.TBL_CARGO
                       where variable.ID_CARGO == int.Parse(id)
                       select variable).Single();
         objeto.NOMBRE_CARGO = nuevo.NOMBRE_CARGO;
         bd.SubmitChanges();
         objJSON.items = objeto;
         objJSON.totalCount = bd.TBL_CARGO.Count();
         objJSON.success = true;
     }
     catch (Exception ex)
     {
         objJSON.success = false;
     }
     return objJSON;
 }