示例#1
0
        public CompanyController(CompaniesContext context)
        {
            this.context = context;

            //It creates a new collection if the collections is empty, no empty view
            if (this.context.Companies.Count() == 0)
            {
                Address startingAddress = new Address {
                    ZipCode = "PA 15464", Country = "EEUU", City = "Mills Run"
                };
                this.context.Addresses.Add(startingAddress);
                long index = startingAddress.ID;
                this.context.Addresses.Add(new Address {
                    ZipCode = "8 Chome-16-10", Country = "Japan", City = "Ginza, Chūō-ku"
                });
                this.context.Addresses.Add(new Address {
                    ZipCode = "WA 98052", Country = "EEUU", City = "Redmond"
                });
                this.context.Companies.Add(new Company {
                    Name = "Weyland-Yutani", Address = this.context.Addresses.Find((long)index++)
                });
                this.context.Companies.Add(new Company {
                    Name = "Jeb Kerman's furniture", Address = this.context.Addresses.Find((long)index++)
                });
                this.context.Companies.Add(new Company {
                    Name = "The Boring Company", Address = this.context.Addresses.Find((long)index)
                });
                this.context.SaveChanges();
            }
        }
示例#2
0
        public void TestMethod1()
        {
            CompaniesContext context = new CompaniesContext();
            var _companies           = new List <Companie>
            {
                new Companie {
                    ParentId = 0, Name = "Coca-cola", Earnings = 74
                },
                new Companie {
                    ParentId = 1, Name = "Fanta", Earnings = 40
                },
                new Companie {
                    ParentId = 2, Name = "Sprite", Earnings = 48
                },
                new Companie {
                    ParentId = 3, Name = "Yupi", Earnings = 32
                }
            };

            _companies.ForEach(s => context.Companies.Add(s));
            context.SaveChanges();
            var companies = context.Companies.ToList();

            Assert.IsTrue(companies.Count > 0);
        }
示例#3
0
        public ListOfEmployees(CompaniesContext db, Guid id)
        {
            InitializeComponent();
            employersIndexes = new List <decimal>();
            this.db          = db;
            Department department = db.Department.Find(id);

            this.Text = department.Name;
            AllEmployee(department);
        }
示例#4
0
 public InsertForm(CompaniesContext db)
 {
     InitializeComponent();
     this.db         = db;
     DepartmentsList = new List <Department>();
     foreach (Department departments in db.Department)
     {
         //if (departments.Department1.Count==0)
         // {
         DepartmentComboBox.Items.Add(departments.Name);
         DepartmentsList.Add(departments);
         // }
     }
 }
示例#5
0
        public Form1()
        {
            InitializeComponent();
            db = new CompaniesContext();
            TreeNode tree = new TreeNode("Фирмы");

            tree.Name = "root";
            treeView1.Nodes.Add(tree);
            IQueryable <Department> roots = db.Department.Where(x => x.ParentDepartmentID == null);

            foreach (Department u in roots)
            {
                ViewTree(u, tree);
            }
        }
示例#6
0
        public EmployeeForm(CompaniesContext db, decimal id)
        {
            InitializeComponent();

            this.db         = db;
            this.id         = id;
            DepartmentsList = new List <Department>();

            this.empoyee      = db.Empoyee.Find(id);
            this.Text         = empoyee.SurName + " " + empoyee.FirstName;
            FirstName.Text    = empoyee.FirstName;
            SurName.Text      = empoyee.SurName;
            Patronymic.Text   = empoyee.Patronymic;
            DateOfBirth.Value = empoyee.DateOfBirth;
            DocSeries.Text    = empoyee.DocSeries;
            DocNumber.Text    = empoyee.DocNumber;
            Position.Text     = empoyee.Position;

            foreach (Department departments in db.Department)
            {
                DepartmentComboBox.Items.Add(departments.Name);
                DepartmentsList.Add(departments);


                if (departments.ID == empoyee.DepartmentID)
                {
                    DepartmentComboBox.SelectedIndex = DepartmentComboBox.Items.Count - 1;
                }
            }

            var today = DateTime.Today;
            var age   = today.Year - empoyee.DateOfBirth.Year;

            if (empoyee.DateOfBirth > today.AddYears(-age))
            {
                age--;
            }
            Age.Text = age.ToString();
        }
		public CompaniesRepository()
		{
			_db = new CompaniesContext();
		}
示例#8
0
 public CompaniesRepository(CompaniesContext dbContext)
     : base(dbContext)
 {
     _companiesContext = dbContext;
 }
 public CompanyService(CompaniesContext companiesContext)
 {
     _companiesContext = companiesContext;
 }
 public EmployeeService(CompaniesContext companiesContext)
 {
     _companiesContext = companiesContext;
 }
示例#11
0
 public PersonService(CompaniesContext companiesContext)
 {
     _companiesContext = companiesContext;
 }
示例#12
0
 public HomeController()
 {
     _employeeDb = new EmployeesContext();
     _companyDb  = new CompaniesContext();
 }
示例#13
0
 public UsersRepository(CompaniesContext db)
 {
     _db = db;
 }
示例#14
0
 public CompaniesContextSeedData(CompaniesContext dbContext)
 {
     _dbContext = dbContext;
 }