public static Customer ConverttoEntity(CustomerModel incustomer)
 {
     Customer customer = null;
        try
        {
        EngineerRepository erepo = new EngineerRepository();
        InstallationRepository irepo = new InstallationRepository();
        customer = new Customer();
        customer.customerid = incustomer.customerid;
        customer.firstname = incustomer.firstname;
        customer.lastname = incustomer.lastname;
        customer.username = incustomer.username;
        customer.password = incustomer.password;
        customer.engineerid = incustomer.engineerid;
        customer.email = incustomer.email;
        customer.Engineer = ConvertEngineer.ConverttoEntity(erepo.GetById(customer.engineerid));
        foreach (var item in incustomer.Installation)
        {
            customer.Installation.Add(ConvertInstallation.ConverttoEntity(irepo.GetById(item)));
        }
        log.Info("CustomerModel wurde konvertiert.");
        }
        catch (Exception exp)
        {
        log.Error("CustomerModel konnte nicht konvertiert werden.");
        throw new DalException("CustomerModel konnte nicht konvertiert werden.", exp);
        }
        return customer;
 }
        public void ShouldReturnCountAllEngineers()
        {
            var repository = new EngineerRepository(mockDbContext.Object);
            var count      = repository.CountAll();

            Assert.Equal(4, count);
        }
        public void ShouldReturnAllEngineers()
        {
            var repository = new EngineerRepository(mockDbContext.Object);
            var engineers  = repository.GetAll();

            Assert.Equal(4, engineers.Count());
        }
        //public ActionResult Details(int id)
        //{
        //    return View();
        //}

        public ActionResult TotalCostsByEngineerReport()
        {
            InterventionRepository iRepo = new InterventionRepository(new ApplicationDbContext());
            EngineerRepository     eRepo = new EngineerRepository();

            var interventions = iRepo.SelectAll();
            var engineers     = eRepo.GetEngineers();

            var report = new EngineerReport(interventions, engineers).Report;

            return(View(report));
        }
        // GET: Accountant
        public ActionResult Index()
        {
            EngineerRepository eRepo = new EngineerRepository();
            ManagerRepository  mRepo = new ManagerRepository();
            DistrictRepository dRepo = new DistrictRepository(new ApplicationDbContext());
            var accountantIndex      = new AccountantIndexViewModel
            {
                Engineers = eRepo.GetEngineers(),
                Managers  = mRepo.GetManagers(),
            };

            return(View(accountantIndex));
        }
        public EngineerReport()
        {
            var engineerReportsRepository = new EngineerRepository();

            Rows = new List <TotalCostByEngineerRow>();

            // populate rows
            foreach (var engineer in engineerReportsRepository.GetEngineers())
            {
                var row = new TotalCostByEngineerRow();
                row.Name       = engineer.Name;
                row.TotalHours = engineer.Hours ?? default(int);
                row.TotalCost  = engineer.Cost ?? default(decimal);

                Rows.Add(row);
            }

            // sort alphabetically
            Rows = Rows.OrderBy(o => o.Name).ToList();
        }
 public static Engineer ConverttoEntity(EngineerModel inengineer)
 {
     Engineer engineer = null;
     try
     {
         EngineerRepository erepo = new EngineerRepository();
         engineer = new Engineer();
         engineer.firstname = inengineer.firstname;
         engineer.lastname = inengineer.lastname;
         engineer.username = inengineer.username;
         engineer.password = inengineer.password;
         engineer.engineerid = inengineer.engineerid;
         engineer.email = inengineer.email;
         log.Info("EngineerModel wurde konvertiert.");
     }
     catch (Exception exp)
     {
         log.Error("EngineerModel konnte nicht konvertiert werden.");
         throw new DalException("EngineerModel konnte nicht konvertiert werden.", exp);
     }
     return engineer;
 }
Example #8
0
        public void AddEntity()
        {
            using (var context = new DataContext())
            {
                IRepository <Dock>     dockRepository     = new DockRepository(context);
                IRepository <Engineer> engineerRepository = new EngineerRepository(context);
                IRepository <Pilot>    pilotRepository    = new PilotRepository(context);
                IRepository <Ship>     shipRepository     = new ShipRepository(context);
                IRepository <Station>  stationRepository  = new StationRepository(context);

                var station = new Station
                {
                    Name     = StationName,
                    Location = StationLocation
                };
                var dock = new Dock {
                    Name = "First dock", CountOfShipsPlaces = 3
                };
                var engineer = new Engineer
                {
                    FirstName     = "Ivan",
                    MiddleName    = "Ivanovich",
                    LastName      = "Ivanov",
                    Biography     = "Very powerfully engineer",
                    Qualification = "Welder"
                };
                var pilot = new Pilot
                {
                    FirstName         = "Raman",
                    MiddleName        = "Igorevich",
                    LastName          = "Dzianishchyk",
                    Biography         = "Born in bla-bla-bla-blar",
                    ExperienceFlights = 3
                };
                var ship = new Ship {
                    Name = "Impetuous"
                };

                station.Docks = new List <Dock>()
                {
                    dock
                };
                station.Engineers = new List <Engineer>()
                {
                    engineer
                };
                pilot.OwnShip     = ship;
                ship.DockRegistry = dock;
                dock.Engineers    = new List <Engineer>()
                {
                    engineer
                };

                stationRepository.Add(station);
                dockRepository.Add(dock);
                engineerRepository.Add(engineer);
                pilotRepository.Add(pilot);
                shipRepository.Add(ship);

                Assert.IsTrue(
                    stationRepository.Count(null) > 0 && shipRepository.Count(null) > 0 &&
                    pilotRepository.Count(null) > 0 && engineerRepository.Count(null) > 0 &&
                    dockRepository.Count(null) > 0);
            }
        }