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

            try
            {
                engineer = ConvertEngineer.ConvertfromEntity(context.Engineer.Find(id));
                log.Info("Engineer wurde geladen.");
            }
            catch (Exception exp)
            {
                log.Error("Engineer konnte nicht geladen werden.");
                throw new DalException("Engineer konnte nicht geladen werden.", exp);
            }
            return(engineer);
        }
Ejemplo n.º 6
0
        public List <EngineerModel> GetAll()
        {
            List <EngineerModel> elist = null;

            try
            {
                IQueryable <Engineer> query = context.Engineer;
                elist = ConvertEngineer.ConvertToList(query);
                log.Info("EngineerEntities wurden geladen.");
            }
            catch (Exception exp)
            {
                log.Error("EngineerEntities konnten nicht geladen werden.");
                throw new DalException("EngineerEntities konnten nicht geladen werden.", exp);
            }
            return(elist);
        }