示例#1
0
        public ActionResult Index()
        {
            var tags   = _tagService.GetAll();
            var models = tags.Select(t => _tagBuilder.BuildViewModel(t)).ToList();

            return(PartialView(models));
        }
示例#2
0
        public void It_should_use_the_tag_builder_to_create_a_list_of_view_models()
        {
            //arrange
            var tags = TestUtilities.GetTestTags();

            A.CallTo(() => _tagService.GetAll(A <Expression <Func <Tag, bool> >[]> .That.IsSameSequenceAs(TestUtilities.EmptyTagFilters()))).Returns(tags);

            //act
            _controller.Index();

            //assert
            A.CallTo(() => _tagBuilder.BuildViewModel(A <Tag> .Ignored)).MustHaveHappened(Repeated.Exactly.Times(tags.Count()));
        }
示例#3
0
 public ComplaintViewModel BuildViewModel(Complaint complaint)
 {
     return(new ComplaintViewModel()
     {
         ComplaintText = complaint.ComplaintText,
         DateSubmitted = complaint.DateCreated.ToShortDateString(),
         FacebookUserId = complaint.FacebookUserId,
         FacebookUserName = complaint.FacebookUserName,
         Id = complaint.Id,
         Latitude = complaint.Latitude,
         Longitude = complaint.Longitude,
         Severity = _complaintSeverityBuilder.BuildViewModel(complaint.Severity),
         Tags = complaint.Tags.Select(t => _tagBuilder.BuildViewModel(t)).ToList()
     });
 }
示例#4
0
        private void PopulateCreateComplaintModel(CreateComplaintViewModel model)
        {
            var severities      = _complaintSeverityService.GetAll();
            var defaultSeverity = severities.Where(s => s.IsDefault).FirstOrDefault();
            var tags            = _tagService.GetAll();

            model.Severities = severities.Select(s => new SelectListItem()
            {
                Text     = s.Name,
                Selected = s.IsDefault,
                Value    = s.Id.ToString()
            });

            model.SelectedComplaintSeverityId = defaultSeverity == null ? (Guid?)null : defaultSeverity.Id;
            model.ExistingTags = tags.Select(t => _tagBuilder.BuildViewModel(t)).ToList();
        }