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);
        }
Beispiel #2
0
 public void Edit(InstallationModel entity)
 {
     try
     {
         context.Entry <Installation>(ConvertInstallation.ConverttoEntity(entity)).State = System.Data.EntityState.Modified;
         log.Info("Installation wurde geändert.");
     }
     catch (Exception exp)
     {
         log.Error("Installation konnte nicht geändert werden.");
         throw new DalException("Installation konnte nicht geändert werden.", exp);
     }
 }
Beispiel #3
0
 public void Delete(InstallationModel entity)
 {
     try
     {
         context.Installation.Remove(ConvertInstallation.ConverttoEntity(entity));
         log.Info("Installation wurde gelöscht.");
     }
     catch (Exception exp)
     {
         log.Error("Installation konnte nicht gelöscht werden.");
         throw new DalException("Installation konnte nicht gelöscht werden.", exp);
     }
 }
Beispiel #4
0
 public void Add(InstallationModel entity)
 {
     try
     {
         context.Installation.Add(ConvertInstallation.ConverttoEntity(entity));
         log.Info("Installation wurde gespeichert.");
     }
     catch (Exception exp)
     {
         log.Error("Installation konnten nicht gespeichert werden.");
         throw new DalException("Installation konnte nicht gespeichert werden.", exp);
     }
 }
Beispiel #5
0
        public InstallationModel GetById(int id)
        {
            InstallationModel installation = null;

            try
            {
                installation = ConvertInstallation.ConvertfromEntity(context.Installation.Find(id));
                log.Info("Installation wurde geladen.");
            }
            catch (Exception exp)
            {
                log.Error("Installation konnte nicht geladen werden.");
                throw new DalException("Installation konnte nicht geladen werden.", exp);
            }
            return(installation);
        }
Beispiel #6
0
        public List <InstallationModel> GetAll()
        {
            List <InstallationModel> ilist = null;

            try
            {
                ilist = new List <InstallationModel>();
                IQueryable <Installation> query = context.Installation;
                ilist = ConvertInstallation.ConvertToList(query);
                log.Info("InstallationEntities wurden geladen.");
            }
            catch (Exception exp)
            {
                log.Error("InstallationEntities konnten nicht geladen werden.");
                throw new DalException("InstallationEntities konnten nicht geladen werden.", exp);
            }
            return(ilist);
        }
Beispiel #7
0
        public List <InstallationModel> GetByCustomerId(int customerid)
        {
            List <InstallationModel> ilist = null;

            try
            {
                IQueryable <Installation> query = from result in context.Installation
                                                  where result.customerid.Equals(customerid)
                                                  select result;
                ilist = ConvertInstallation.ConvertToList(query);
                log.Info("Installations von Customer wurden geladen.");
            }
            catch (Exception exp)
            {
                log.Error("Installations von Customer konnten nicht geladen werden.");
                throw new DalException("Installation von Customer konnten nicht geladen werden.", exp);
            }

            return(ilist);
        }