Exemplo n.º 1
0
 public List<Model.Company> GetAllCompany()
 {
     List<Company> allCompany = new List<Company>();
     using (Model1Container context = new Model1Container())
     {
         allCompany = context.Company.ToList();
     }
     return allCompany;
 }
Exemplo n.º 2
0
        public List<Company> GetAllCompanyForMarket(string market)
        {
            List<Company> allCompany = new List<Company>();

            using (Model1Container context = new Model1Container())
            {
                allCompany = context.Company.Where(c => c.Market.ToLower().Equals(market.ToLower())).ToList();
            }
            return allCompany;
        }
Exemplo n.º 3
0
        public List<Company> GetAllCompanyByMarket(string MarketSearchCriteria)
        {
            List<Company> allCompany = new List<Company>();

            using (Model1Container context = new Model1Container())
            {
                allCompany = context.Company.Where(c => c.Market.Contains(MarketSearchCriteria)).ToList();
            }
            return allCompany;
        }
Exemplo n.º 4
0
 public bool CreateCompany(Company companyfromVM)
 {
     Company company;
     bool succes = true;
     try
     {
         using (Model1Container context = new Model1Container())
         {
             company = context.Company.Add(companyfromVM);
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         succes = false;
     }
     return succes;
 }
Exemplo n.º 5
0
 public Api()
 {
     _ctx = new Model1Container();
 }
Exemplo n.º 6
0
 public Model.Company GetCompagnyByID(int ID)
 {
     Company company;
     using (Model1Container context = new Model1Container())
     {
         company = context.Company.Find(ID);
     }
     return company;
 }
Exemplo n.º 7
0
 public bool UpdateCompany(Company companyfromVM)
 {
     Company company;
     bool succes = true;
     try
     {
         using (Model1Container context = new Model1Container())
         {
             company = context.Company.Find(companyfromVM.ID);
             context.Entry(company).CurrentValues.SetValues(companyfromVM);
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         succes = false;
     }
     return succes;
 }
Exemplo n.º 8
0
        public List<Company> GetCompanyByName(string NameSearchCriteria)
        {
            List<Company> allCompany = new List<Company>();

            using (Model1Container context = new Model1Container())
            {
                allCompany = context.Company.Where(c => c.Name.Contains(NameSearchCriteria)).ToList();
            }
            return allCompany;
        }
Exemplo n.º 9
0
        //dans cette methode gestion des recherches multis criteres
        public List<Company> GetCompanyByCriteria(string NameSearchCriteria, string MarketSearchCriteria, string MailSearchCriteria)
        {
            List<Company> allCompany = new List<Company>();

            using (Model1Container context = new Model1Container())
            {
                if (string.IsNullOrEmpty(NameSearchCriteria))
                {
                    allCompany = context.Company.Where(c => c.Mail.Contains(MailSearchCriteria) && c.Market.Contains(MarketSearchCriteria)).ToList();
                }
                else if (string.IsNullOrEmpty(MailSearchCriteria))
                {
                    allCompany = context.Company.Where(c => c.Name.Contains(NameSearchCriteria) && c.Market.Contains(MarketSearchCriteria)).ToList();
                }
                else if (string.IsNullOrEmpty(MarketSearchCriteria))
                {
                    allCompany = context.Company.Where(c => c.Name.Contains(NameSearchCriteria) && c.Mail.Contains(MailSearchCriteria)).ToList();
                }
                else
                {
                    allCompany = context.Company.Where(c => c.Name.Contains(NameSearchCriteria) && c.Mail.Contains(MailSearchCriteria) && c.Market.Contains(MarketSearchCriteria)).ToList();
                }
            }

            return allCompany;
        }