Esempio n. 1
0
        public void TestMethodGetAllStudent()
        {
            context           = new SampleDbEntities();
            unitOfWork        = new UnitOfWork();
            studentRepository = new StudentRepository(context);
            studentService    = new StudentService(unitOfWork, studentRepository);
            stud = new Student();

            int nb = studentService.GetAll().ToList().Count();

            //stud = studentService.GetById(i);
            Assert.AreEqual(3, nb);
        }
Esempio n. 2
0
        public void TestDeleteStudent()
        {
            context           = new SampleDbEntities();
            unitOfWork        = new UnitOfWork();
            studentRepository = new StudentRepository(context);
            studentService    = new StudentService(unitOfWork, studentRepository);
            stud = studentService.GetById(16);

            using (var dbContextTransaction = context.Database.BeginTransaction())
            {
                studentService.Delete(stud);
                dbContextTransaction.Rollback();
            }
        }
Esempio n. 3
0
 public void GetInfoGrid()
 {
     using (var context = new SampleDbEntities())
     {
         var students = (from stud in context.Students
                         select new
         {
             stud.Id,
             stud.FirstName,
             stud.LastName,
             stud.Email,
             stud.EnrollmentNumber,
             Department = stud.Departement.Title
         }).ToList();
     }
 }
Esempio n. 4
0
        public void TestUpdateStudent()
        {
            string updatedName = "name updated";

            context           = new SampleDbEntities();
            unitOfWork        = new UnitOfWork();
            studentRepository = new StudentRepository(context);
            studentService    = new StudentService(unitOfWork, studentRepository);
            stud           = studentService.GetById(16);
            stud.FirstName = updatedName;

            using (var dbContextTransaction = context.Database.BeginTransaction())
            {
                studentService.Update(stud);
                dbContextTransaction.Rollback();
            }
        }
Esempio n. 5
0
 public void TestInsertStudent()
 {
     context           = new SampleDbEntities();
     unitOfWork        = new UnitOfWork();
     studentRepository = new StudentRepository(context);
     studentService    = new StudentService(unitOfWork, studentRepository);
     stud = new Student()
     {
         FirstName        = "test name",
         LastName         = "last name",
         Email            = "*****@*****.**",
         EnrollmentNumber = "123456",
         AddedDate        = DateTime.ParseExact("2017-12-07 14:40:52,531", "yyyy-MM-dd HH:mm:ss,fff",
                                                System.Globalization.CultureInfo.InvariantCulture),
         ModifiedDate = DateTime.ParseExact("2017-12-07 14:40:52,531", "yyyy-MM-dd HH:mm:ss,fff",
                                            System.Globalization.CultureInfo.InvariantCulture)
     };
     using (var dbContextTransaction = context.Database.BeginTransaction())
     {
         studentService.Create(stud);
         dbContextTransaction.Rollback();
     }
 }
Esempio n. 6
0
        private void GetColumNames()
        {
            ColumnNames = new List <string>();
            using (SampleDbEntities context = new SampleDbEntities())
            {
                var objectContext   = ((IObjectContextAdapter)context).ObjectContext;
                var storageMetadata = ((EntityConnection)objectContext.Connection).GetMetadataWorkspace().GetItems(DataSpace.SSpace);
                var entityProps     = (from sm in storageMetadata where sm.BuiltInTypeKind == BuiltInTypeKind.EntityType select sm as EntityType);
                // For your project, open the model browser to get the name for the model, will have namespace.Store

                var metaData = typeof(Student).GetProperties()
                               .Select(property => property.Name)
                               .ToArray();

                //var metaData = (from m in entityProps where m.FullName == "NORTHWNDModel.Store.Customers" select m.DeclaredProperties).ToList();
                foreach (var topItem in metaData)
                {
                    foreach (var item in topItem)
                    {
                        ColumnNames.Add(item.ToString());
                    }
                }
            }
        }
Esempio n. 7
0
 public UnitOfWork()
 {
     context = new SampleDbEntities();
 }
Esempio n. 8
0
 public UnitOfWork(SampleDbEntities context)
 {
     this.context = context;
 }
Esempio n. 9
0
 public OrderRepository(SampleDbEntities dbContext)
 {
     _dbContext = dbContext;
 }
Esempio n. 10
0
 public DepartementRepository(SampleDbEntities context)
     : base(context)
 {
 }
Esempio n. 11
0
 public Repository(SampleDbEntities context)
 {
     this.context = context;
 }
Esempio n. 12
0
 public HurricanesController()
 {
     _context = new SampleDbEntities();
 }
Esempio n. 13
0
 public StudentRepository(SampleDbEntities context)
     : base(context)
 {
 }
 public CustomerRepository(SampleDbEntities dbContext)
 {
     _dbContext = dbContext;
 }
 public ContactsRepositoryWithUow(SampleDbEntities _entities)
 {
     entities = _entities;
 }