Пример #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 Show(int id)
        {
            var obj = ProjectSourceLogic.Get(id);

            if (obj == null)
            {
                this.AddError("ProjectSourceNotFound", "That ProjectSource was not found");
                return(Redirect(Url.ProjectSource_Index()));
            }
            var model = ModelConverter.ConvertToShow(obj);

            return(View(model));
        }
Пример #3
0
        public void Get_Id_Not_Found()
        {
            //arrange
            int id = 0;
            ProjectSourceObj expected = null;
            var mockRepository        = new Mock <IInnerTrackRepository>();

            mockRepository.Setup(m => m.GetProjectSources(It.Is <ProjectSourceFilter>(f => f.Id == id))).Returns(new List <ProjectSourceObj> {
            });
            var logic = new ProjectSourceLogic(mockRepository.Object);

            //act
            var actual = logic.Get(id);

            //assert
            Assert.AreEqual(expected, actual);
        }