Exemplo n.º 1
0
        public void Search_ThrowsException()
        {
            // Arrange
            int      id    = 123;
            string   title = "naziv";
            DateTime from  = DateTime.Now;
            DateTime to    = DateTime.Now.AddDays(10);

            var usersOnMeeting = new List <UserMeetingDto>()
            {
                new UserMeetingDto()
                {
                    UserId = 1
                }
            };

            var meeting = new MeetingsSearchModel()
            {
                MeetingId   = id,
                Title       = title,
                From        = from,
                To          = to,
                UserMeeting = usersOnMeeting
            };

            var meetingRepo         = new Mock <IMeetingsRepository>();
            var meetingManipulation = new MeetingsManipulation(meetingRepo.Object);
            var controller          = new MeetingsController(meetingManipulation);

            var result = controller.Search(meeting, 1, 1);

            // Assert
            Assert.IsType <ObjectResult>(result);
        }
        private void Search(MeetingsSearchModel searchModel)
        {
            searchModel.SearchResult = SessionService.DbContainer.Resolve <MeetingDataManager>()
                                       .SearchMeetings(Convert.ToInt32(searchModel.Country), searchModel.Racecourse, searchModel.StartDate,
                                                       searchModel.EndDate);

            SessionService.SearchModel = searchModel;
        }
        public ActionResult Index(MeetingsSearchModel searchModel)
        {
            if (ModelState.IsValid && !(searchModel.IsCreateNew ?? false))
            {
                Search(searchModel);
            }

            return(View(searchModel));
        }
Exemplo n.º 4
0
        public IActionResult Search([FromBody] MeetingsSearchModel model, int pageNumber, int pageSize)
        {
            try
            {
                if (model == null)
                {
                    throw new NSIException("MeetingSearchModel is null", DC.Exceptions.Enums.Level.Error, DC.Exceptions.Enums.ErrorType.InvalidParameter);
                }

                MeetingDto meetingDto = new MeetingDto()
                {
                    MeetingId   = model.MeetingId,
                    To          = model.To,
                    Title       = model.Title,
                    From        = model.From,
                    UserMeeting = model.UserMeeting.Select(x => new UserMeetingDto()
                    {
                        UserId   = x.UserId,
                        UserName = x.UserName
                    })
                };

                return(Ok(new NSIResponse <ICollection <MeetingDto> > {
                    Data = _meetingsManipulation.SearchMeetings(meetingDto, pageNumber, pageSize), Message = "Success"
                }));
            }
            catch (NSIException ex)
            {
                Logger.Logger.LogError(ex);
                if (ex.ErrorType == DC.Exceptions.Enums.ErrorType.MissingData)
                {
                    return(NoContent());
                }
                return(BadRequest(new NSIResponse <object> {
                    Data = null, Message = "Parameter error!"
                }));
            }
            catch (Exception ex)
            {
                Logger.Logger.LogError(ex);
                return(StatusCode(500, new NSIResponse <object> {
                    Data = null, Message = ex.Message
                }));
            }
        }