Esempio n. 1
0
        public void TestEditCustomer(int id)
        {
            //var cdl = new CustomerDataLayer((MyDbContext)dbContext);
            using (var context = new MyDbContext(dbContext))
            {
                var      service  = new CustomerDataLayer(context);
                int      response = 1;
                Customer cust     = new Customer();
                cust.CustomerID = id;
                cust.FirstName  = "Prajith";
                cust.LastName   = "Maniyan";
                cust.DOB        = DateTime.Now;

                Customer temp = service.getCustomer(id);
                if (temp == null)
                {
                    response = -1;
                }
                else
                {
                    response = 1;
                }

                int ret = service.editCustomer(cust);

                Assert.Equal(response, ret);
            }
        }
Esempio n. 2
0
        public void GetCustomerTest()
        {
            CustomerDataLayer customerDataLayer = new CustomerDataLayer();
            var cust = customerDataLayer.GetForName("aaron");

            Assert.IsNotNull(cust);
        }
Esempio n. 3
0
        public List <CustomerInfo> getAllCustomer(int pageSize, int pageIndex)
        {
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                List <CustomerInfo> ListCustomer = CustomerDataLayer.GetInstance().GetAllCustomer(connection);
                //int min = pageIndex * pageSize;
                //int max = pageIndex * pageSize + pageSize;

                //if (min > ListCustomer.Count) return new List<CustomerInfo>();
                //if (max >= ListCustomer.Count) pageSize = ListCustomer.Count - min;
                //if (pageSize <= 0) return new List<CustomerInfo>();
                return(ListCustomer);
            }
            //
            //SqlConnectionFactory sqlConnection = new SqlConnectionFactory();
            //using (SqlConnection connection = sqlConnection.GetConnection())
            //{
            //    List<CustomerInfo> ListCustomer = CustomerDataLayer.GetInstance().GetAllCustomer(connection);
            //    int min = pageIndex * pageSize;
            //    int max = pageIndex * pageSize + pageSize;

            //    if (min > ListCustomer.Count) return new List<CustomerInfo>();
            //    if (max >= ListCustomer.Count) pageSize = ListCustomer.Count - min;
            //    if (pageSize <= 0) return new List<CustomerInfo>();
            //    return ListCustomer.GetRange(min, pageSize);
            //}
        }
Esempio n. 4
0
        public ContractPrintModel GetNegotiationPrintModel(int contractID, string _userID)
        {
            ContractPrintModel   record        = new ContractPrintModel();
            NegotiationInfo      info          = new NegotiationInfo();
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();
            NewContractInfo      contractInfo  = getContractNew(contractID, _userID);

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                info = NegotiationDataLayer.GetInstance().getNegotiation(connection, contractInfo.NegotiationID, _userID);
                if (record == null || info == null)
                {
                    return(null);
                }

                CustomerInfo cusInfo = CustomerDataLayer.GetInstance().getCustomer(connection, info.CustomerID);

                record.ContractCode = contractInfo.ContractCode;
                record.DateIn       = contractInfo.DateIn;
                record.ASide        = "BỆNH VIỆN TRUYỀN MÁU HUYẾT HỌC";
                record.BSide        = info.CustomerName;

                record.ALocation  = info.Location;
                record.APhone     = info.Phone;
                record.AFax       = info.Fax;
                record.ABankID    = info.BankID;
                record.ATaxCode   = info.TaxCode;
                record.ARepresent = info.Represent;
                record.APosition  = info.Position;

                record.BLocation       = cusInfo.Address;
                record.BPhone          = cusInfo.Phone;
                record.BFax            = cusInfo.Fax;
                record.BBankID         = cusInfo.BankNumber + " " + cusInfo.BankName;
                record.BTaxCode        = cusInfo.TaxCode;
                record.BRepresent      = cusInfo.Surrogate;
                record.BPosition       = cusInfo.Position;
                record.NegotiationTime = info.DateIn;
                record.Term            = info.Term;
                record.NegotiationCode = info.NegotiationCode;
                record.VATNumber       = info.VATNumber;
                record.IsVAT           = info.IsVAT;
                record.QuoteTotalCost  = info.QuoteTotalCost;
                record.Items           = QuoteDataLayer.GetInstance().getSelectedItemsQuote(connection,
                                                                                            record.QuoteID);
                record.QuoteID   = info.QuoteID;
                record.QuoteCode = info.QuoteCode;


                record.BidType          = info.BidType;
                record.BidExpirated     = info.BidExpirated;
                record.BidExpiratedUnit = info.BidExpiratedUnit;

                record.Items = QuoteDataLayer.GetInstance().getSelectedItemsQuote(connection,
                                                                                  record.QuoteID);

                return(record);
            }
        }
Esempio n. 5
0
 public int?CreateCustomer(NewCustomer customer)
 {
     if (customer != null)
     {
         return(CustomerDataLayer.CreateCustomer(customer.Firstname, customer.Lastname));
     }
     return(null);
 }
Esempio n. 6
0
        public List <CustomerInfo> getCustomer(CustomerSeachCriteria _criteria)
        {
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                List <CustomerInfo> ListCustomer = CustomerDataLayer.GetInstance().getCustomer(connection, _criteria);
                return(ListCustomer);
            }
        }
Esempio n. 7
0
        public CustomerInfo getCustomerbyId(string _bidPlanCode)
        {
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                CustomerInfo Customer = CustomerDataLayer.GetInstance().getCustomerByBidPlanCode(connection, _bidPlanCode);
                return(Customer);
            }
        }
Esempio n. 8
0
        public CustomerInfo getCustomerbyId(int _ID)
        {
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                CustomerInfo Customer = CustomerDataLayer.GetInstance().getCustomer(connection, _ID);
                return(Customer);
            }
        }
Esempio n. 9
0
        public int getNewId()
        {
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                List <CustomerInfo> ListCustomer = CustomerDataLayer.GetInstance().GetAllCustomer(connection);
                CustomerInfo        lastCustomer = ListCustomer.Last();
                if (lastCustomer != null)
                {
                    return(lastCustomer.CustomerID + 1);
                }
                return(1);
            }
        }
Esempio n. 10
0
        public void TestAddCustomers()
        {
            //var cdl = new CustomerDataLayer((MyDbContext)dbContext);
            using (var context = new MyDbContext(dbContext))
            {
                var service = new CustomerDataLayer(context);

                Customer cust = new Customer();
                cust.CustomerID = 1;
                cust.FirstName  = "Praj";
                cust.LastName   = "Man";
                cust.DOB        = DateTime.Now;

                int ret = service.addCustomer(cust);

                Assert.Equal(1, ret);
            }
        }
Esempio n. 11
0
        public void TestSearchCustomer(string str)
        {
            //var cdl = new CustomerDataLayer((MyDbContext)dbContext);
            using (var context = new MyDbContext(dbContext))
            {
                var service = new CustomerDataLayer(context);

                Customer temp = service.searchCustomer(str);
                Customer ret  = null;
                if (temp != null)
                {
                    ret = service.getCustomer(temp.CustomerID);
                }
                else
                {
                    ret = null;
                }

                Assert.Equal(temp, ret);
            }
        }
Esempio n. 12
0
        public void TestDeleteCustomer(int id)
        {
            //var cdl = new CustomerDataLayer((MyDbContext)dbContext);
            using (var context = new MyDbContext(dbContext))
            {
                var service  = new CustomerDataLayer(context);
                int response = 1;

                Customer temp = service.getCustomer(id);
                if (temp == null)
                {
                    response = -1;
                }
                else
                {
                    response = 1;
                }

                int ret = service.deleteCustomer(1);

                Assert.Equal(response, ret);
            }
        }
Esempio n. 13
0
 public Customer GetCusomer(int customer)
 {
     return(CustomerDataLayer.GetCustomer(customer));
 }
Esempio n. 14
0
 public bool DeleteCustomer(int customer)
 {
     return(CustomerDataLayer.DeleteCustomer(customer));
 }
Esempio n. 15
0
 public CustomerController(MyDbContext dbContext)
 {
     custDataLayer = new CustomerDataLayer(dbContext);
 }