public static void createNewRequisitionList(Dictionary <string, List <RequisitionDetail> > dictionary) { UniversityStoreEntities context = new UniversityStoreEntities(); foreach (KeyValuePair <string, List <RequisitionDetail> > kvp in dictionary) { DateTime d = DateTime.Now; Employee emp = context.Employees.First <Employee>(x => x.EmployeeNumber == kvp.Key); RequisitionList rl = new RequisitionList(); rl.DepartmentCode = emp.DepartmentCode; rl.EmployeeNumber = emp.EmployeeNumber; rl.DateCreated = DateTime.Now; rl.Status = STATUS_PENDING; EntityCollection <RequisitionDetail> listDetails = new EntityCollection <RequisitionDetail>(); foreach (RequisitionDetail detail in kvp.Value) { listDetails.Add(detail); } rl.RequisitionDetails = listDetails; context.AddToRequisitionLists(rl); context.SaveChanges(); } }
public static RequisitionList addNewReqList(string empNumber) { UniversityStoreEntities context = new UniversityStoreEntities(); DateTime d = DateTime.Now; Employee emp = context.Employees.First <Employee>(x => x.EmployeeNumber == empNumber); RequisitionList rl = new RequisitionList(); rl.DepartmentCode = emp.DepartmentCode; rl.EmployeeNumber = emp.EmployeeNumber; rl.DateCreated = DateTime.Now; rl.Status = STATUS_PENDING; context.AddToRequisitionLists(rl); context.SaveChanges(); return(rl); }