public ActionResult Index(string txtSearch, int?WarehouseId, int?BranchId) { IQueryable <PhysicalInventoryViewModel> list = PhysicalInventoryRepository.GetAllvwPhysicalInventory() .Where(x => x.Type == PhysicalInventoryType.Product) .Select(item => new PhysicalInventoryViewModel { Id = item.Id, IsDeleted = item.IsDeleted, Code = item.Code, CreatedDate = item.CreatedDate, ModifiedDate = item.ModifiedDate, Note = item.Note, WarehouseId = item.WarehouseId, WarehouseName = item.WarehouseName, IsExchange = item.IsExchange, CancelReason = item.CancelReason, CreatedUserName = item.CreatedUserName, ProductInboundCode = item.ProductInboundCode, ProductOutboundCode = item.ProductOutboundCode, BranchId = item.BranchId, BranchName = item.BranchName, }).OrderByDescending(x => x.CreatedDate); if (!SecurityFilter.IsAdmin()) { list = list.Where(x => x.BranchId == Helpers.Common.CurrentUser.BranchId); } else { if (BranchId != null) { list = list.Where(x => x.BranchId == BranchId); } } if (!string.IsNullOrEmpty(txtSearch)) { txtSearch = txtSearch.ToLower(); list = list.Where(x => x.Code.ToLower().Contains(txtSearch)); } if (WarehouseId != null) { list = list.Where(x => x.WarehouseId == WarehouseId); } return(View(list)); }
public ViewResult Index(int?BranchId, string txtCode, string txtCusName, string startDate, string endDate) { IEnumerable <RePayPointsViewModel> q = vwRePayPointsService.Get() .Select(item => new RePayPointsViewModel { Id = item.Id, IsDeleted = item.IsDeleted, CreatedUserId = item.CreatedUserId, CreatedDate = item.CreatedDate, ModifiedUserId = item.ModifiedUserId, ModifiedDate = item.ModifiedDate, Code = item.Code, Status = item.Status, IsArchive = item.IsArchive, CustomerId = item.CustomerId, CustomerName = item.CustomerName, BranchId = item.BranchId, BranchName = item.BranchName, Note = item.Note, SaleName = item.SaleName, CancelReason = item.CancelReason, AvailabilityPoint = item.AvailabilityPoint, TotalPoint = item.TotalPoint, WarehouseSourceName = item.WarehouseSourceName }).OrderByDescending(m => m.ModifiedDate); if (!SecurityFilter.IsAdmin()) { q = q.Where(x => x.BranchId == Helpers.Common.CurrentUser.BranchId); } else { if (BranchId != null) { q = q.Where(x => x.BranchId == BranchId); } } //Lọc theo ngày DateTime d_startDate, d_endDate; if (DateTime.TryParseExact(startDate, "dd/MM/yyyy", new CultureInfo("vi-VN"), DateTimeStyles.None, out d_startDate)) { if (DateTime.TryParseExact(endDate, "dd/MM/yyyy", new CultureInfo("vi-VN"), DateTimeStyles.None, out d_endDate)) { d_endDate = d_endDate.AddHours(23).AddMinutes(59); q = q.Where(x => x.CreatedDate >= d_startDate && x.CreatedDate <= d_endDate); } } if (!string.IsNullOrEmpty(txtCode)) { q = q.Where(x => x.Code == txtCode); } if (!string.IsNullOrEmpty(txtCusName)) { q = q.Where(x => x.CustomerName.Contains(txtCusName)); } ViewBag.SuccessMessage = TempData["SuccessMessage"]; ViewBag.FailedMessage = TempData["FailedMessage"]; ViewBag.AlertMessage = TempData["AlertMessage"]; return(View(q)); }