예제 #1
0
        public int Insert(Core.Domain.Customer model, ref string ErrorMsg)
        {
            int ID = 0;

            db = new SqlConnection(ConfigurationManager.ConnectionStrings["cnConsumption"].ConnectionString);
            string sql = " INSERT INTO tblCustomer(ContractNo,CustomerName,MobileNo,FlatNo,BuildingID,Deposit) " +
                         " VALUES (@ContractNo,@CustomerName,@MobileNo,@FlatNo,@BuildingID,@Deposit)";

            try
            {
                ID = db.Execute(sql, new
                {
                    model.ContractNo,
                    model.CustomerName,
                    model.MobileNo,
                    model.FlatNo,
                    model.BuildingID,
                    model.Deposit
                });
            }
            catch (Exception e)
            {
                if (e.Message.IndexOf("PK_tblCustomer") > 0)
                {
                    ErrorMsg = "Contract No Already Exist....";
                }
                else
                {
                    ErrorMsg = e.Message;
                }
                db.Close();
                return(0);
            }
            return(ID);
        }
예제 #2
0
        //Query By Example methods
        public IList<Customer> GetCustomersByExample(Customer customer)
        {
            ISession _session = GetSession();
            var customers = _session.CreateCriteria<Customer>()
                .Add(Example.Create(customer))
                .List<Customer>();

            return customers;
        }
        public void CanGetCustomersByExample()
        {
            var ipCustomer = new Customer { FirstName = "Khaja" };
            var customers = _repo.GetCustomersByExample(ipCustomer);

            Assert.IsNotNull(customers);
            Assert.IsInstanceOfType(typeof(IList<Customer>), customers);
            foreach (var cust in customers) {
                Assert.AreEqual("Khaja", cust.FirstName, StringComparison.OrdinalIgnoreCase);
            }
            Assert.IsTrue(customers.Count > 0);
        }
        public void Should_persist_customer()
        {
            var customer = new Customer
                           {
                              EmailAddress = "*****@*****.**",
                              Name = "joe",
                              PhoneNumber = "817-555-1212"
                           };

             store.Store(customer);

             Recycle();

             var reloadedCustomer = query.ById<Customer>(1);

             Assert.That(reloadedCustomer, Is.EqualTo(customer));
        }
        public void Should_query_with_linq()
        {
            var customer = new Customer{Name = "john", EmailAddress = "*****@*****.**", PhoneNumber = "800"};
             var customer1 = new Customer{Name = "john", EmailAddress = "*****@*****.**", PhoneNumber = "800"};

             store.Store(customer);
             store.Store(customer1);
             store.Store(new Customer{Name = "joe", EmailAddress = "*****@*****.**", PhoneNumber = "800"});
             store.Store(new Customer{Name = "john", EmailAddress = "*****@*****.**", PhoneNumber = "801"});

             Recycle();

             var customers = query.Query<Customer>().Where(x => x.PhoneNumber == "800" && x.Name == "john").ToList();

             CollectionAssert.Contains(customers, customer);
             CollectionAssert.Contains(customers, customer1);
             Assert.That(customers.Count(), Is.EqualTo(2));
        }
예제 #6
0
 public Order(Customer customer)
 {
     _customer = customer;
 }
예제 #7
0
 public void Update(Core.Domain.Customer model)
 {
     throw new NotImplementedException();
 }
예제 #8
0
 public int Insert(Core.Domain.Customer model, ref string ErrorMsg)
 {
     IRepository = new CustomerRepository();
     return(IRepository.Insert(model, ref ErrorMsg));
 }