예제 #1
0
 public int UpdateDepartments(department[] departments)
 {
     if (departments == null)
     {
         return(0);
     }
     using (IOPContext cxt = new IOPContext())
     {
         DepartmentConverter depCvt = new DepartmentConverter(cxt);
         foreach (var d in departments)
         {
             Department dep = depCvt.FromDto(d, cxt.Departments.Find(d.id));
             cxt.Entry(dep).State = System.Data.Entity.EntityState.Modified;
         }
         return(cxt.SaveChanges());
     }
 }
예제 #2
0
 public int AddDepartments(IEnumerable <department> departments)
 {
     if (departments == null)
     {
         return(0);
     }
     using (IOPContext cxt = new IOPContext())
     {
         List <Department>   dList  = new List <Department>();
         DepartmentConverter depCvt = new DepartmentConverter(cxt);
         foreach (var d in departments)
         {
             Department dep = depCvt.FromDto(d);
             dList.Add(dep);
         }
         cxt.Departments.AddRange(dList);
         return(cxt.SaveChanges());
     }
 }