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); } }
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); }
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); }
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); }
public ActionResult JQDataTable() { var customer = new CustomerViewModel(); return View(customer); }
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); }