public CustomerEntity GetCustomerByCustomerId(int customerId)
 {
     _logger.DebugFormat("GetCustomerByCustomerId");
     using (var db = new MuscleTherapyContext())
     {
         return db.Customers.Find(customerId);
     }
 }
 public List<CustomerEntity> GetAllCustomers()
 {
     _logger.DebugFormat("GetAllCustomers");
     using (var db = new MuscleTherapyContext())
     {
         return db.Customers.ToList();
     }
 }
        public List<AfflictionAreaEntity> GetAfflicationAreasByCustomerId(int customerId)
        {
            _logger.Debug("GetAfflicationAreas by customerId");

            using (var db = new MuscleTherapyContext())
            {
                var result = from AfflictionAreaEntity aae in db.AfflictionAreas
                             where (aae.CustomerId == customerId)
                             select aae;

                return result.ToList();
            }
        }
        public List<AfflictionAreaEntity> GetAfflicationAreas(int treatmentId)
        {
            _logger.Debug("GetAfflicationAreas");

            using (var db = new MuscleTherapyContext())
            {
                var result = from AfflictionAreaEntity aae in db.AfflictionAreas
                    where (aae.TreatmentId == treatmentId)
                    select aae;

                return result.ToList();
            }
        }
        public bool DeleteAfflictions(List<AfflictionAreaEntity> request)
        {
            _logger.DebugFormat("DeleteAfflictions with request count: {0}", request.Count);

            using (var db = new MuscleTherapyContext())
            {
                foreach (var afflictionAreaEntity in request)
                {
                    db.Entry(afflictionAreaEntity).State = EntityState.Deleted;
                }

                db.SaveChanges();
            }
            return true;
        }
 public void UpdateNewCustomer(CustomerEntity customer)
 {
     _logger.DebugFormat("Updating new customer");
     using (var db = new MuscleTherapyContext())
     {
         db.Customers.Add(customer);
         db.SaveChanges();
     }
 }
        public void UpdateExistingCustomer(CustomerEntity customer)
        {
            _logger.DebugFormat("Updating Existing customer with customerId: {0}", customer.CustomerId);

            using (var db = new MuscleTherapyContext())
            {
                db.Customers.Attach(customer);
                db.Entry(customer).State = EntityState.Modified;
                db.SaveChanges();
            }
        }