예제 #1
0
        public void LoadMachines()
        {
            using (var applicationDbContext = new ApplicationDbContext())
            {
                // reset
                _machines.Items.Clear();

                // load databases
                var lstMachines = applicationDbContext.Machines.Where(x => !x.IsDeleted).OrderBy(x => x.Name).ToList();

                //var dbMachines = context.Machines; // define query
                //var lstMachines = dbMachines.ToList(); // query executed and data obtained from database
                foreach (var machine in lstMachines)
                {
                    var machineVM = new MachineViewModel
                    {
                        Id              = machine.Id,
                        Name            = machine.Name,
                        Code            = machine.Code,
                        TagIndex        = machine.TagIndex,
                        CumulativeCount = machine.CumulativeCount
                    };
                    _machines.Items.Add(machineVM);
                }
            }
        }
예제 #2
0
 public PlanViewModel(Plan plan)
 {
     _id               = plan.Id;
     _machineId        = plan.MachineId;
     _employeeId       = plan.EmployeeId;
     _productId        = plan.ProductId;
     _expectedQuantity = plan.ExpectedQuantity;
     _actualQuantity   = plan.ActualQuantity;
     //_startTime = plan.StartTime;
     //_endTime = plan.EndTime;
     _totalMilliseconds = plan.TotalMilliseconds;
     _isProcessed       = plan.IsProcessed;
     _createdOn         = plan.CreatedOn;
     _modifiedOn        = plan.ModifiedOn;
     Product            = new ProductViewModel(plan.Product);
     Machine            = new MachineViewModel(plan.Machine);
     Employee           = new EmployeeViewModel(plan.Employee);
     Db = new DBX();
 }