public JsonResult GetAll() { var response = new JsonResultBody(); response.Status = System.Net.HttpStatusCode.OK; try { var data = _repository.GetAll(); response.Data = Mapper.Map <IEnumerable <UnitType>, IEnumerable <UnitTypeViewModel> >(data); } catch (DbEntityValidationException ex) { response.Status = System.Net.HttpStatusCode.InternalServerError; foreach (DbEntityValidationResult result in ex.EntityValidationErrors) { response.Errors = (from ve in result.ValidationErrors select ve.ErrorMessage).ToList(); } } catch (Exception ex) { response.Status = System.Net.HttpStatusCode.InternalServerError; response.Errors.Add(ex.Message); } return(Json(response, JsonRequestBehavior.AllowGet)); }
private void InitFilter() { Filter = new UnitFilter(); ComplexFilterParams = new UnitFilterParams(); var unitTypeRepository = new UnitTypeRepository(); FilterUnitTypeList = unitTypeRepository.GetAll(type => type.TypeName); var repository = Repository as UnitRepository; if (repository != null) { FilterManufactureList = repository.GetManufactureList(); FilterModelNameList = repository.GetModelList(); } var ownerRepository = new OwnerRepository(); FilterOwnerList = ownerRepository.GetAll(owner => owner.Name.DisplayName); var statusRepository = new StatusRepository(); FilterStatusList = statusRepository.GetAll(x => x.StatusType); }