public ActionResult Create(string customerName, string phone, string address, string customerRemark)
        {
            if (customerName.Equals(string.Empty))
            {
                ModelState.AddModelError("customerName", "輸入客戶姓名");
            }

            if (phone.Equals(string.Empty))
            {
                ModelState.AddModelError("phone", "請輸入電話號碼");
            }

            Comm_Customer data = CustomerModel.getCustomerCountByphone(phone);

            if (data != null)
            {
                ModelState.AddModelError("Phone", "已有相同手機。");
            }

            if (!ModelState.IsValid)
            {
                return(View());
            }

            Comm_Customer customer = new Comm_Customer();

            customer.customerName   = customerName;
            customer.phone          = phone;
            customer.address        = address;
            customer.customerRemark = customerRemark;

            CustomerModel.Create(customer);
            return(RedirectToAction("Index"));
        }
Beispiel #2
0
        public ActionResult Customer()
        {
            var list = _personService.GetList().OrderByDescending(n => n.CreatedDate);

            var models = list.Select(n => CustomerModel.Create(n, _appContext)).ToList();

            return(View(models));
        }
Beispiel #3
0
        public IActionResult Get([FromQuery] CustomerFilter customerFilter)
        {
            var currentUser = CurrentUser.Create(HttpContext);

            var filter = customerFilter.ToPredicate(currentUser);

            var customers = _customerService.GetAll(filter).Select(customer => CustomerModel.Create(customer));

            return(Ok(new
            {
                success = true,
                data = customers
            }));
        }