public IActionResult Search([FromQuery] YachtMerchantProductVendorSearchModel model) { var result = _yachtMerchantProductVendorServices.Search(model); if (result.IsSuccessStatusCode) { return(Ok(result)); } return(BadRequest()); }
public BaseResponse <PagedList <YachtMerchantProductVendorViewModel> > Search(YachtMerchantProductVendorSearchModel model) { try { var query = (from i in _context.YachtMerchantProductVendors .Where(k => !k.Deleted && k.MerchantFid == model.MerchantId && (string.IsNullOrEmpty(model.VendorName) || k.Name.Contains(model.VendorName)) && (model.VendorTypeId == 0 || k.VendorTypeFid == model.VendorTypeId) && (model.CategoryId == 0 || k.ProductCategoryFid == model.CategoryId)) select new YachtMerchantProductVendorViewModel() { Name = i.Name, Id = i.Id, VendorTypeFid = i.VendorTypeFid, VendorTypeResKey = i.VendorTypeResKey, ProductCategoryFid = i.ProductCategoryFid, ProductCategoryResKey = i.ProductCategoryResKey, Email = i.Email, ContactNo = i.ContactNo, Count = _context.YachtMerchantProductSuppliers.Where(x => x.VendorFid == i.Id && !x.Deleted).Count(), }).OrderByDescending(x => x.Id); return(BaseResponse <PagedList <YachtMerchantProductVendorViewModel> > .Success(new PagedList <YachtMerchantProductVendorViewModel>(query, model.PageIndex, model.PageSize))); } catch (Exception ex) { return(BaseResponse <PagedList <YachtMerchantProductVendorViewModel> > .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace)); } }