Beispiel #1
0
 public bool Insert(Customer cus)
 {
     try
     {
         ManageCustomersEntities ctx = new ManageCustomersEntities();
         ctx.Customers.Add(cus);
         ctx.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Beispiel #2
0
        public bool Delete(int id)
        {
            try
            {
                using (ManageCustomersEntities ctx = new ManageCustomersEntities())
                {
                    var _ob = ctx.Customers.SingleOrDefault(b => b.ID == id);
                    if (_ob != null)
                    {
                        ctx.Customers.Remove(_ob);
                        ctx.SaveChanges();
                    }
                }

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Beispiel #3
0
        public bool Update(int id, Customer cus)
        {
            try
            {
                using (ManageCustomersEntities ctx = new ManageCustomersEntities())
                {
                    var _ob = ctx.Customers.SingleOrDefault(b => b.ID == id);
                    if (_ob != null)
                    {
                        _ob.Name    = cus.Name.Trim();
                        _ob.Phone   = cus.Phone.Trim();
                        _ob.Email   = cus.Email.Trim();
                        _ob.Address = cus.Address.Trim();
                        ctx.SaveChanges();
                    }
                }

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Beispiel #4
0
 public BaseDal()
 {
     _entities = new ManageCustomersEntities(ConnectionString);
 }
Beispiel #5
0
        public Customer GetByID(int id)
        {
            ManageCustomersEntities ctx = new ManageCustomersEntities();

            return(ctx.Customers.Where(c => c.ID == id).ToArray()[0] as Customer);
        }
Beispiel #6
0
        public Customer[] GetALL()
        {
            ManageCustomersEntities ctx = new ManageCustomersEntities();

            return(ctx.Customers.ToArray());
        }