コード例 #1
0
        public void AddOrUpdate(Customer customer)
        {
            if (string.IsNullOrEmpty(customer.Name) ||
                string.IsNullOrEmpty(customer.Address) ||
                string.IsNullOrEmpty(customer.Phone)
                )
            {
                throw new Exception("Input is not valid");
            }

            try
            {
                if (_customerDAO.GetById(customer.Id) == null)
                {
                    _customerDAO.Add(customer);
                }
                else
                {
                    _customerDAO.Update(customer);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
0
        public ActionResult RegistrationInserting()
        {
            string userName = Request.Params["username"];
            string password = Request.Params["password"];
            string name     = Request.Params["name"];
            string lname    = Request.Params["lname"];
            string tel      = Request.Params["tel"];
            string email    = Request.Params["email"];
            string address  = Request.Params["addr"];

            CustomerModel cModel = new CustomerModel();

            cModel.CUST_UID         = UID.ranByLen(8);
            cModel.USERNAME         = userName;
            cModel.PASSWORD         = password;
            cModel.C_NAME           = name;
            cModel.C_LASTNAME       = lname;
            cModel.C_ADDRESS        = address;
            cModel.C_TEL            = tel;
            cModel.C_EMAIL          = email;
            cModel.PRIORITY         = new PriorityModel();
            cModel.PRIORITY.PRIO_ID = 3;


            Database    db   = new Database();
            CustomerDAO cDAO = new CustomerDAO(db);
            int         cID  = cDAO.Add(cModel);

            db.Close();

            return(RedirectToAction("CheckLogin_Customer", "Login", new { custID = cID }));
        }
コード例 #3
0
 public static bool CreateNewCustomer(Customer Customer)
 {
     try
     {
         return(CustomerDAO.Add(Customer));
     }
     catch (Exception ex)
     {
         Logger.getInstance().log(ex.ToString());
         return(false);
     }
 }
コード例 #4
0
 public static bool Add(Customer entity)
 {
     return(CustomerDAO.Add(entity));
 }