Exemple #1
0
        // GET api/customerapi
        public IEnumerable <CCustomer> Get(string customerCode, string customerName, string owner, int page)
        {
            var user = (CSign)HttpContext.Current.Session[ConfigurationManager.AppSettings["AuthSaveKey"]];

            if (user == null)
            {
                throw new HttpResponseException(new SiginFailureMessage());
            }
            using (var dal = DalBuilder.CreateDal(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString, 0))
            {
                CCustomer[] customers;
                try
                {
                    dal.Open();
                    customers = CustomerBll.List(dal, customerCode, customerName, owner, page);
                    dal.Close();
                }
                catch (Exception ex)
                {
                    LogBll.Write(dal, new CLog
                    {
                        LogUser    = string.Format("{0}-{1}", user.UserCode, user.UserName),
                        LogContent = string.Format("{0}#{1}", "Customer.List", ex.Message),
                        LogType    = LogType.系统异常
                    });
                    throw new HttpResponseException(new SystemExceptionMessage());
                }

                if (customers == null)
                {
                    throw new HttpResponseException(new DataNotFoundMessage());
                }
                return(customers);
            }
        }
Exemple #2
0
        /*
         *   // GET: Customers
         * public ActionResult Index()
         * {
         *  return View(db.Customers.ToList());
         * }
         *
         * // GET: Customers/Details/5
         * public ActionResult Details(int? id)
         * {
         *  if (id == null)
         *  {
         *      return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
         *  }
         *  Customer customer = db.Customers.Find(id);
         *  if (customer == null)
         *  {
         *      return HttpNotFound();
         *  }
         *  return View(customer);
         * }
         *
         * // GET: Customers/Create
         * public ActionResult Create()
         * {
         *  return View();
         * }
         *
         * // POST: Customers/Create
         * // To protect from overposting attacks, please enable the specific properties you want to bind to, for
         * // more details see https://go.microsoft.com/fwlink/?LinkId=317598.
         * [HttpPost]
         * [ValidateAntiForgeryToken]
         * public ActionResult Create([Bind(Include = "Id,Name,Code,ContactNo,Email,Image,Address")] Customer customer)
         * {
         *  if (ModelState.IsValid)
         *  {
         *      db.Customers.Add(customer);
         *      db.SaveChanges();
         *      return RedirectToAction("Index");
         *  }
         *
         *  return View(customer);
         * }
         *
         * // GET: Customers/Edit/5
         * public ActionResult Edit(int? id)
         * {
         *  if (id == null)
         *  {
         *      return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
         *  }
         *  Customer customer = db.Customers.Find(id);
         *  if (customer == null)
         *  {
         *      return HttpNotFound();
         *  }
         *  return View(customer);
         * }
         *
         * // POST: Customers/Edit/5
         * // To protect from overposting attacks, please enable the specific properties you want to bind to, for
         * // more details see https://go.microsoft.com/fwlink/?LinkId=317598.
         * [HttpPost]
         * [ValidateAntiForgeryToken]
         * public ActionResult Edit([Bind(Include = "Id,Name,Code,ContactNo,Email,Image,Address")] Customer customer)
         * {
         *  if (ModelState.IsValid)
         *  {
         *      db.Entry(customer).State = EntityState.Modified;
         *      db.SaveChanges();
         *      return RedirectToAction("Index");
         *  }
         *  return View(customer);
         * }
         *
         * // GET: Customers/Delete/5
         * public ActionResult Delete(int? id)
         * {
         *  if (id == null)
         *  {
         *      return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
         *  }
         *  Customer customer = db.Customers.Find(id);
         *  if (customer == null)
         *  {
         *      return HttpNotFound();
         *  }
         *  return View(customer);
         * }
         *
         * // POST: Customers/Delete/5
         * [HttpPost, ActionName("Delete")]
         * [ValidateAntiForgeryToken]
         * public ActionResult DeleteConfirmed(int id)
         * {
         *  Customer customer = db.Customers.Find(id);
         *  db.Customers.Remove(customer);
         *  db.SaveChanges();
         *  return RedirectToAction("Index");
         * }
         *
         */

        #endregion

        // GET: Items
        public ActionResult List()
        {
            List <Customer> Parties = _customerBll.List();

            return(View(Parties));
        }