示例#1
0
        public T Add(T itemToAdd)
        {
            var entity = dbContext.Add <T>(itemToAdd);

            dbContext.SaveChanges();
            return(entity.Entity);
        }
        public void SaveChanges()
        {
            dbContext.SaveChanges();
            if (currentTransactionScope != null)
            {
                currentTransactionScope.Complete();
            }

            currentTransactionScope = null;
        }
 public void AddEmployee(string userId, string name, string email, string role)
 {
     if (role == "Driver")
     {
         var driver = Driver.Create(userId, name, email);
         DbContext.Drivers.Add(driver);
     }
     else if (role == "Supervisor")
     {
         var supervisor = Supervisor.Create(userId, name, email);
         DbContext.Supervisors.Add(supervisor);
     }
     else if (role == "Dispatcher")
     {
         var dispatcher = Dispatcher.Create(userId, name, email);
         DbContext.Dispatchers.Add(dispatcher);
     }
     DbContext.SaveChanges();
 }