コード例 #1
0
        public ActionResult Edit(int?id = null)
        {
            EditProjectSourceModel model = null;
            int?currentConfigTypeId      = null;

            if (id.HasValue)
            {
                var obj = ProjectSourceLogic.Get(id.Value);
                if (obj != null)
                {
                    model = ModelConverter.ConvertToEdit(obj);
                    currentConfigTypeId = obj.SourceConfig.Id;
                }
                else
                {
                    this.AddWarning("NoProjectSourceFound", "No ProjectSource was found with that Id. Switching to Create mode.");
                    return(Redirect(Url.ProjectSource_Create()));
                }
            }

            if (model == null)
            {
                model = new EditProjectSourceModel();
            }

            var availableTypeItems = ProjectSourceTypeLogic.GetAll()
                                     .Select(c => new SelectListItem {
                Text  = c.Name,
                Value = c.Id.ToString()
            });

            model.AvailableTypes = new SelectList(availableTypeItems, availableTypeItems.FirstOrDefault(a => a.Value == currentConfigTypeId.ToString()));

            return(View("Edit", model));
        }
コード例 #2
0
        public ActionResult Index()
        {
            var model = new ListProjectSourceTypeModel();
            var objs  = ProjectSourceTypeLogic.GetAll();

            model.ProjectSourceTypes = ModelConverter.Convert(objs);
            return(View(model));
        }
コード例 #3
0
        public void GetAll_No_ProjectSourceTypes_Found()
        {
            //arrange
            var mockRepository = new Mock <IInnerTrackRepository>();

            mockRepository.Setup(m => m.GetProjectSourceTypes(It.Is <ProjectSourceTypeFilter>(f => !f.Id.HasValue))).Returns(new List <ProjectSourceTypeObj>());
            var logic = new ProjectSourceTypeLogic(mockRepository.Object);

            //act
            var actual = logic.GetAll();

            //assert
            Assert.IsNotNull(actual);
            Assert.AreEqual(0, actual.Count);
        }