Exemplo n.º 1
0
        public void AddCustomertoDB(string fn, string ln, string phone)
        {
            using (var context = new Project1Context(Options))
            {
                var _tempcustomer = new Customers
                {
                    FirstName = fn,
                    LastName  = ln,
                    Phone     = phone
                };

                context.Add(_tempcustomer);
                context.SaveChanges();
            }
        }
Exemplo n.º 2
0
        public List <Customers> searchbylastname(string ln)
        {
            List <Customers> _tempList = new List <Customers>();

            using (var context = new Project1Context(Options))
            {
                var query = from Customers in context.Customers where Customers.LastName == ln select Customers;
                foreach (var x in query)
                {
                    _tempList.Add(x);
                }
            }

            return(_tempList);
        }
Exemplo n.º 3
0
        public Customers customerDetails(int id)
        {
            Customers _customerDetails = new Customers();

            using (var context = new Project1Context(Options))
            {
                var query = from Customers in context.Customers where Customers.Id == id select Customers;
                foreach (var x in query)
                {
                    _customerDetails.Id        = x.Id;
                    _customerDetails.FirstName = x.FirstName;
                    _customerDetails.LastName  = x.LastName;
                    _customerDetails.Phone     = x.Phone;
                }
            }

            return(_customerDetails);
        }
 //initializes a new Project0 Repository given an available Database
 public Project1Repository(Project1Context dbContext)
 {
     _dbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext));
 }