Ejemplo n.º 1
0
 public ActionResult Add()
 {
     try
     {
         CustomerViewModel customerViewModel = new CustomerViewModel();
         var countryGuid = _countryService.GetCountryGuidBy3DigitCode("USA");
         customerViewModel.CountryId                   = countryGuid;
         customerViewModel.AgencySelectListItems       = new Dictionary <string, string>();
         customerViewModel.DepartmentSelectListItems   = _usCustomerOfficeListService.GetUsCustomerOfficeDepartmentList().ToDictionary(x => x.DepartmentName, x => x.DepartmentName);
         customerViewModel.CustomerTypeSelectListItems = _customerTypeService.GetCustomerTypeList().ToDictionary(x => x.CustomerTypeGuid, x => x.CustomerTypeName);
         customerViewModel.CountrySelectListItems      = _countryService.GetCountryList().ToDictionary(x => x.CountryId, x => x.CountryName);
         customerViewModel.StateSelectListItems        = _stateRepository.GetStateByCountryGuid(customerViewModel.CountryId).ToDictionary(x => x.StateId, x => x.StateName);
         return(PartialView(customerViewModel));
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("", ex.Message);
         return(BadRequestFormatter.BadRequest(this, ex));
     }
 }
 public JsonResult GetCustomerDepartment()
 {
     try
     {
         var departmentList = _usCustomerOfficeListService.GetUsCustomerOfficeDepartmentList();
         var model          = (from c in departmentList select new KeyValuePairModel <string, string> {
             Keys = c.DepartmentName, Values = c.DepartmentName
         }).ToList();
         model.Insert(0, new KeyValuePairModel <string, string> {
             Keys = null, Values = "--Select--"
         });
         return(Json(model));
     }
     catch
     {
         return(Json(""));
     }
 }