Exemple #1
0
        public async Task <List <LitigationDto> > SearchLitigationsAsync(LitigationSearchDto searchDto)
        {
            var litigationUsers = dbContext.LitigationUser.Where(lu => searchDto.UsersIds.Contains(lu.UserId)).AsEnumerable();
            var litigationsIds  = litigationUsers.Select(lu => lu.LitigationId);

            var litigations = await dbContext.Litigation.Where(l => (((searchDto.Defendant == null) || (searchDto.Defendant == 0)) || ((searchDto.Defendant != null) && l.Defendant == searchDto.Defendant)) &&
                                                               (((searchDto.Prosecutor == null) || (searchDto.Prosecutor == 0)) || ((searchDto.Prosecutor != null) && l.Defendant == searchDto.Prosecutor)) &&
                                                               (((searchDto.CourtroomNumber == null) || (searchDto.CourtroomNumber == 0)) || ((searchDto.CourtroomNumber != null) && l.CourtroomNumber == searchDto.CourtroomNumber)) &&
                                                               (((searchDto.ProcessIdentifier == null) || (searchDto.ProcessIdentifier == "")) || ((searchDto.ProcessIdentifier != null) && l.ProcessIdentifier == searchDto.ProcessIdentifier)) &&
                                                               (((searchDto.InstitutionType == null) || (searchDto.InstitutionType == 0)) || ((searchDto.InstitutionType != null) && l.InstitutionType == searchDto.InstitutionType)) &&
                                                               (((searchDto.Judge == null) || (searchDto.Judge == 0)) || ((searchDto.Judge != null) && l.Judge == searchDto.Judge)) &&
                                                               (((searchDto.LocationId == null) || (searchDto.LocationId == 0)) || ((searchDto.LocationId != null) && l.LocationId == searchDto.LocationId)) &&
                                                               (((searchDto.FromDateAndTime == null) || (searchDto.ToDateAndTime == null)) || ((searchDto.FromDateAndTime != null) && (l.DateAndTime >= searchDto.FromDateAndTime && l.DateAndTime <= searchDto.ToDateAndTime))) &&
                                                               ((searchDto.UsersIds == null) || ((searchDto.UsersIds.Count() > 0) && litigationsIds.Contains(l.Id))) &&
                                                               (((searchDto.ProcessType == null) || (searchDto.ProcessType == 0)) || ((searchDto.ProcessType != null) && l.Defendant == searchDto.ProcessType)))
                              .Include(l => l.Location)
                              .Include(l => l.ProcessTypeNavigation)
                              .Include(l => l.JudgeNavigation)
                              .Include(l => l.DefendantNavigation)
                              .Include(l => l.ProsecutorNavigation)
                              .Include(l => l.LitigationUsers)
                              .ToListAsync();

            var litigationsDtos = litigations.Select(l => mapper.Map <LitigationDto>(l)).ToList();

            return(litigationsDtos);
        }
        public async Task <List <LitigationDto> > SearchLitigationsAsync(LitigationSearchDto searchDto)
        {
            var loggedUser = await litigationPlannerUnitOfWork.ApplicationUserRepository.GetByUsernameAsync(searchDto.loggedUserUsername);

            if (searchDto.UsersIds == null)
            {
                searchDto.UsersIds = new List <string>();
            }

            searchDto.UsersIds.Add(loggedUser.Id);

            var litigations = await litigationPlannerUnitOfWork.LitigationRepository.SearchLitigationsAsync(searchDto);

            return(litigations);
        }
Exemple #3
0
        public async Task <IActionResult> SearchLitigationsAsync(SearchLitigationsViewModel searchModel)
        {
            try
            {
                LitigationSearchDto searchDto = new LitigationSearchDto
                {
                    FromDateAndTime    = searchModel.FromDateAndTime,
                    ToDateAndTime      = searchModel.ToDateAndTime,
                    LocationId         = searchModel.LocationId,
                    Judge              = searchModel.Judge,
                    InstitutionType    = searchModel.InstitutionType,
                    ProcessIdentifier  = searchModel.ProcessIdentifier,
                    CourtroomNumber    = searchModel.CourtroomNumber,
                    Prosecutor         = searchModel.Prosecutor,
                    Defendant          = searchModel.Defendant,
                    ProcessType        = searchModel.ProcessType,
                    UsersIds           = searchModel.UsersIds,
                    loggedUserUsername = HttpContext.User.Identity.Name
                };

                var litigations = await litigationService.SearchLitigationsAsync(searchDto);

                LitigationsListViewModel viewModel = new LitigationsListViewModel()
                {
                    Litigations  = litigations,
                    Contacts     = await contactService.GetAsync(),
                    Locations    = await locationService.GetAsync(),
                    ProcessTypes = await processTypeService.GetAsync(),
                    Users        = await applicationUserService.GetAsync()
                };

                return(View("Views/Litigation/LitigationsListForUser.cshtml", viewModel));
            }
            catch (Exception ex)
            {
                ErrorViewModel errorModel = new ErrorViewModel();
                errorModel.ErrorMessage = ex.Message.ToString();

                return(View("Views/Shared/Error.cshtml", errorModel));
            }
        }