Exemple #1
0
 public HttpResponseMessage Post(Models.CustomerService cs)
 {
     if (ModelState.IsValid)
     {
         _customerServices.SaveOrUpdate(cs);
         return(new HttpResponseMessage(HttpStatusCode.OK));
     }
     else
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
     }
 }
 public JsonResult DeleteCustomer(string CustomerID)
 {
     try
     {
         Models.CustomerService CustomerService = new Models.CustomerService();
         CustomerService.DeleteCustomerById(CustomerID);
         return(this.Json(true));//成功回傳TRUE
     }
     catch (Exception)
     {
         return(this.Json(false));//失敗回傳FALSE
     }
 }
        public ActionResult InsertCustomer(Models.Customer Customer)
        {
            Models.CustomerService orderService = new Models.CustomerService();
            int CustomerID = orderService.InsertCustomer(Customer);

            //檢查是否驗證成功
            if (ModelState.IsValid)
            {
                TempData["ok"] = "成功新增訂單";
                return(RedirectToAction("Index", new { CustomerID = CustomerID }));
            }


            return(View("InsertOrder", Customer));
        }
        public ActionResult UpdateCustomer(Models.Customer Customer)
        {
            Models.CustomerService orderService = new Models.CustomerService();


            //檢查是否驗證成功
            if (ModelState.IsValid)
            {
                CustomerService.UpdateOrder(Customer);
                TempData["ok"] = "成功更新訂單";
                return(RedirectToAction("Index"));
            }
            ViewBag.Emp = this.CustomerService.GetContactTitle();
            return(View("UpdateOrder", Customer));
        }
Exemple #5
0
        public JsonResult Search(SearchCondition sc)
        {
            Models.CustomerService  CustomerService = new Models.CustomerService();
            List <Models.Customers> customers       = CustomerService.GetOrderByCondition(sc);
            List <Object>           results         = new List <Object>();

            for (int i = 0; i < customers.Count; i++)
            {
                Models.Customers order = customers[i];
                results.Add(new
                {
                    CustomerID = order.CustomerID,
                });
            }
            return(Json(results, JsonRequestBehavior.AllowGet));
        }
 public JsonResult Customer(Models.CustomerSearchArg arg)
 {
     ViewBag.EmpCodeData = this.CustomerService.GetContactTitle();
     Models.CustomerService CustomerService = new Models.CustomerService();
     return(Json(CustomerService.GetCustomerByCondtioin(arg)));
 }