Ejemplo n.º 1
0
 public void Create(tblCatalogType oCatalogType)
 {
     try
     {
         using (var ctx = new CRUDSampleEntities())
         {
             ctx.tblCatalogTypes.Add(oCatalogType);
             ctx.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 2
0
 public void Delete(int id)
 {
     try
     {
         using (var ctx = new CRUDSampleEntities())
         {
             tblCatalogType oCatalogType = ctx.tblCatalogTypes.Where(c => c.TypeId == id).FirstOrDefault();
             ctx.tblCatalogTypes.Remove(oCatalogType);
             ctx.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 3
0
 public void Delete(int id)
 {
     try
     {
         using (var ctx = new CRUDSampleEntities())
         {
             tblStudent oStudent = ctx.tblStudents.Where(c => c.StudentId == id).FirstOrDefault();
             ctx.tblStudents.Remove(oStudent);
             ctx.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 4
0
        public void Create(tblStudent oStudent)
        {
            try
            {
                using (var ctx = new CRUDSampleEntities())
                {
                    oStudent.ModifiedDate = DateTime.Now;

                    oStudent.CreateDate = DateTime.Now;
                    oStudent.ModifiedDate = DateTime.Now;
                    ctx.tblStudents.Add(oStudent);

                    ctx.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 5
0
 public void Update(tblCatalogType oCatalogType)
 {
     try
     {
         using (var ctx = new CRUDSampleEntities())
         {
             ctx.Entry(oCatalogType).State = EntityState.Modified;
             ctx.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 6
0
        public void Update(tblStudent oStudent)
        {
            try
            {
                using (var ctx = new CRUDSampleEntities())
                {
                    ctx.tblContactDetails.Attach(oStudent.tblContactDetail);
                    ctx.Entry(oStudent.tblContactDetail).State = EntityState.Modified;

                    ctx.tblStudents.Attach(oStudent);
                    ctx.Entry(oStudent).State = EntityState.Modified;

                    ctx.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }