Exemple #1
0
        public ActionResult Add(CustomerViewModel model)
        {
            try
            {
                //var validationResult = GetValidationResult();
                //if (validationResult != null) return validationResult;
                //bool result = _userService.Save(model.ToMap<CustomerViewModel, Customer>());
                //_persist.Commit();
                ////return Json(new { success = true }, JsonRequestBehavior.AllowGet);
                //if (result)
                //    model.result = "true";
                //ModelState.Clear();
                ////return View(model);
                return RedirectToAction("Index");

            }
            catch (DbEntityValidationException e)
            {
                var validationResult = GetEntityValidationResult(e);
                return validationResult;
            }
            catch (Exception e)
            {

                return Json(new JsonErrorMessage("An error occurred while saving customer."),
                           JsonRequestBehavior.AllowGet);
            }
        }
Exemple #2
0
        public JsonResult getCountryName(string term)
        {
            var customer = new CustomerViewModel();
            //customer.countrtlist = _userService.Fetch().Select(x => x.Country).Take(5).ToList();
            customer.stateList= _userService.Fetch().Select(s => s.City).ToSelectList(x => x, x => x, emptyItem: null).Take(5).ToList();

            return Json(customer.stateList, JsonRequestBehavior.AllowGet);
        }
Exemple #3
0
        public ActionResult CustomerData(CustomerViewModel model, DataTableConfig param)
        {
            List<Customer> customerList = _userService.Fetch().ToList();
            Mapper.CreateMap<Customer, CustomerViewModel>();
            var list = Mapper.Map<List<CustomerViewModel>>(customerList);

            //return Json(new JQueryDataTablesResponse<Customer>(items: listData,
            //    totalRecords: listData.Count(),
            //    totalDisplayRecords: listData.Count(),
            //    sEcho: jQueryDataTablesModel.sEcho));

            return Json(new
            {
                sEcho = param.sEcho,
                iTotalRecords = list.Count(),
                iTotalDisplayRecords = list.Count(),
                aaData = list

            }, JsonRequestBehavior.AllowGet);
        }
Exemple #4
0
 public ActionResult Add()
 {
     CustomerViewModel model = new CustomerViewModel();
     model.stateList = _userService.Fetch().Select(s => s.City).ToSelectList(x => x, x => x, emptyItem: null).ToList();    //code for binding a dropdown list
     return View(model);
 }
Exemple #5
0
 public ActionResult JQDataTable()
 {
     var customer = new CustomerViewModel();
     return View(customer);
 }
Exemple #6
0
 public JsonResult getCountryName(string term)
 {
     var customer = new CustomerViewModel();
     customer.countrtlist = _userService.Fetch().Select(s => s.Country).ToList();
     return Json(customer.countrtlist.ToString(), JsonRequestBehavior.AllowGet);
 }