public ViewResultBase Search(ReportMovementsInputDto model) { try { model.CompanyName = _currentUser.CompanyName; var entities = _reportMovementsAppService.SearchReportMovements(model); model.Cellars = _reportMovementsAppService.GetAllCellars(_currentUser.CompanyName); //model.Projects = _reportMovementsAppService.GetAllProjects(_currentUser.CompanyName); model.Users = _reportMovementsAppService.GetAllUsers(_currentUser.CompanyName); model.ProjectName = model.ProjectName; model.CurrentUserName = _currentUser.UserName; model.CurrentDateTime = _date.Now; model.Movements = entities; model.ErrorCode = ErrorCodeHelper.Ok; model.ErrorDescription = ""; } catch (Exception e) { model.ErrorCode = ErrorCodeHelper.Error; model.ErrorDescription = "Error al buscar los Movimientos"; } //if (Request.IsAjaxRequest()) //{ // return PartialView("_searchStockReportSearchPartial", model); //} return(View("Index", model)); }
public ActionResult Index() { ReportMovementsInputDto model = new ReportMovementsInputDto(); try { model.Query = ""; model.CompanyName = _currentUser.CompanyName; model.Movements = _reportMovementsAppService.SearchReportMovements(model); model.Cellars = _reportMovementsAppService.GetAllCellars(_currentUser.CompanyName); //model.Projects = _reportMovementsAppService.GetAllProjects(_currentUser.CompanyName); model.Users = _reportMovementsAppService.GetAllUsers(_currentUser.CompanyName); model.CurrentUserName = _currentUser.UserName; model.CurrentDateTime = _date.Now; model.Control = "ReportMovements"; model.Action = "Search"; model.ErrorCode = ErrorCodeHelper.Ok; model.ErrorDescription = ""; } catch (Exception e) { model.ErrorCode = ErrorCodeHelper.Error; model.ErrorDescription = "Error al buscar los Movimientos"; } return(View(model)); }
public IEnumerable <Movement> SearchReportMovements(ReportMovementsInputDto searchInput) { var query = ""; if (searchInput.Query != null) { query = searchInput.Query.ToLower(); } var movementsList = _movementsRepository.GetAll(); movementsList = movementsList.Where(a => a.IsDeleted == false && a.Asset.Name.ToLower().Contains(query) || a.Asset.Code.ToLower().Equals(query) || a.Asset.Code.ToLower().Contains(query) || a.Asset.Code.ToLower().Equals(query)); if (searchInput.CellarId != null) { movementsList = movementsList.Where(a => a.CellarId == searchInput.CellarId.Value); } if (searchInput.ProjectId != null) { movementsList = movementsList.Where(a => a.ProjectId == searchInput.ProjectId.Value); } if (searchInput.UserId != null) { movementsList = movementsList.Where(a => a.UserId == searchInput.UserId.Value); } if (searchInput.BeginDateTime != null) { movementsList = movementsList.Where(a => a.ApplicationDateTime >= searchInput.BeginDateTime.Value); } if (searchInput.EndDateTime != null) { movementsList = movementsList.Where(a => a.ApplicationDateTime <= searchInput.EndDateTime.Value); } return(movementsList.Include(a => a.Asset).Include(a => a.Cellar).Include(a => a.User).Include(a => a.Project).OrderBy(a => a.ApplicationDateTime).ToList()); }