public HttpResponseMessage GetCategorySelectList(HttpRequestMessage request, Guid? id = null) { FindResult<SubCategoryViewModel> findSubCategoryResult = new FindResult<SubCategoryViewModel>(); if (id.HasValue) { findSubCategoryResult = subCategoryActivity.GetAllSubcategoriesByCategory(id.Value); } else { findSubCategoryResult = subCategoryActivity.GetAllSubcategories(); } SelectEntityModelListResult<SubCategoryViewModel> selectSubCategories = null; HttpResponseMessage response = null; return GetHttpResponse(request, () => { if (findSubCategoryResult.Success) { selectSubCategories = new SelectEntityModelListResult<SubCategoryViewModel>(findSubCategoryResult.Entities); selectSubCategories.Success = true; } else { selectSubCategories = new SelectEntityModelListResult<SubCategoryViewModel>(new List<SubCategoryViewModel>()); selectSubCategories.Success = false; } response = new HttpResponseMessage(HttpStatusCode.OK); response.Content = new ObjectContent<SelectEntityModelListResult<SubCategoryViewModel>>(selectSubCategories, Configuration.Formatters.JsonFormatter); return response; }); }
public HttpResponseMessage GetCategorySelectList(HttpRequestMessage request) { FindResult<VolumeMeasureViewModel> findVolumeMeasureResult = _volumeMeasureRepository.GetAll(); SelectEntityModelListResult<VolumeMeasureViewModel> selectVolumeMeasures = null; HttpResponseMessage response = null; return GetHttpResponse(request, () => { if (findVolumeMeasureResult.Success) { selectVolumeMeasures = new SelectEntityModelListResult<VolumeMeasureViewModel>(findVolumeMeasureResult.Entities); selectVolumeMeasures.Success = true; } else { selectVolumeMeasures = new SelectEntityModelListResult<VolumeMeasureViewModel>(new List<VolumeMeasureViewModel>()); selectVolumeMeasures.Success = false; } response = new HttpResponseMessage(HttpStatusCode.OK); response.Content = new ObjectContent<SelectEntityModelListResult<VolumeMeasureViewModel>>(selectVolumeMeasures, Configuration.Formatters.JsonFormatter); return response; }); }
public HttpResponseMessage GetSupplierSelectList(HttpRequestMessage request) { return GetHttpResponse(request, () => { HttpResponseMessage response = null; FindResult<SupplierViewModel> supplierResult = supplierRepository.GetAll(); if (supplierResult.Success) { SelectEntityModelListResult<SupplierViewModel> supplierSelectList = new SelectEntityModelListResult<SupplierViewModel>( supplierResult.Entities); supplierSelectList.Success = true; response = new HttpResponseMessage(HttpStatusCode.OK); response.Content = new ObjectContent<SelectEntityModelListResult<SupplierViewModel>>(supplierSelectList, Configuration.Formatters.JsonFormatter); } else { response = new HttpResponseMessage(HttpStatusCode.InternalServerError); } return response; }); }