public void GetProject_NotFound(long id) { using (var context = new ApiContext(contextOptions)) { var service = new ProjectAppService(context, mapperProvider, _projectValidator.Object); var controller = new ProjectsController(service); Func <Task> action = async() => await controller.getProject(id); action.Should().Throw <NotFoundException>(); } }
public void GetProject_Success(long id) { using (var context = new ApiContext(contextOptions)) { var service = new ProjectAppService(context, mapperProvider, _projectValidator.Object); var controller = new ProjectsController(service); var result = controller.getProject(id); Assert.IsAssignableFrom <OkObjectResult>(result.Result); } }
public static ProjectsController ConfigController(ApiContext context, string data, MapperProvider mapperProvider, Mock <IProjectValidator> projectValidator) { var service = new ProjectAppService(context, mapperProvider, projectValidator.Object); var controllerContext = new ControllerContext() { HttpContext = ConfigRequest(data), }; var controller = new ProjectsController(service) { ControllerContext = controllerContext }; return(controller); }
// GET: Project/Edit/5 public ActionResult Edit(int id) { if (id <= 0) { return(RedirectToAction("Index")); } var entity = new ProjectAppService().Get(id); if (entity == null) { return(RedirectToAction("Index")); } var model = GetModelFromEntity(entity); return(View(model)); }
/// <summary> /// 基于评审实例的操作 /// </summary> /// <returns></returns> public async Task <ActionResult> ReviewInstance() { var review = await GetCurrentReview(); if (review == null || review.CurrentReviewRound == null || review.CurrentReviewRound.ReviewStatus != Reviews.ReviewStatus.Reviewing) { return(RedirectToAction("Index")); } var appConfiguration = _env.GetAppConfiguration(); var loginInfo = await _sessionAppService.GetCurrentLoginInformations(); ViewData["softTitle"] = appConfiguration["System:SoftTitle"]; ViewData["reviewInstance"] = review; List <ReviewProject> reviewProjects = review.ReviewProjects; var sourceProjectIds = review.CurrentReviewRound.SourceProjectIDs.Split(',').Select(o => int.Parse(o)); reviewProjects = reviewProjects.Where(o => sourceProjectIds.Contains(o.Id)).ToList(); List <Project> projects; if (review.CurrentReviewRound.ReviewMethod != Reviews.ReviewMethod.Vote) { //非投票类型的评审需要移除当前专家回避的项目 reviewProjects = reviewProjects.Where(o => !o.IsAvoidedByExpert(AbpSession.UserId.Value)).ToList(); } //获取所有待评审项目 projects = await ProjectRepository.GetAllIncluding(o => o.Prize, o => o.DesignOrganization).Include(o => o.PrizeSubMajor).ThenInclude(o => o.Major).Where(o => reviewProjects.Select(r => r.Id).Contains(o.Id)).ToListAsync(); //暂存的数据 List <ProjectReviewDetail> projectReviewDetails = new List <ProjectReviewDetail>(); var expertReviewDetail = review.CurrentReviewRound.ExpertReviewDetails.SingleOrDefault(o => o.ExpertID == AbpSession.UserId.Value); if (expertReviewDetail != null) { projectReviewDetails = expertReviewDetail.ProjectReviewDetails; } ViewData["ReviewProjects"] = reviewProjects; ViewData["ReviewProjectDtos"] = await ProjectAppService.ProjectToReviewProjectDtos(reviewProjects); ViewData["Projects"] = projects; ViewData["ProjectReviewDetails"] = projectReviewDetails; return(View(loginInfo)); }
public ActionResult Create(ProjectViewModel model) { try { var result = new ProjectAppService().Create(model.GetEntity()); if (result != null && result.Id > 0) { return(RedirectToAction("Index")); } ViewBag.ErrorMessage = "Erro ao inserir Projeto"; return(View()); } catch { ViewBag.ErrorMessage = "Erro ao inserir Projeto"; return(View()); } }
/// <summary> /// 评选活动详情 /// </summary> /// <param name="data"></param> /// <returns></returns> public async Task <IActionResult> ReviewEdit(int data) { var matchInstance = await GetCurrentMatchInstance(); var review = await ReviewRepository.GetAllIncluding(o => o.ReviewRounds).SingleOrDefaultAsync(o => o.Id == data); //获取对应的专家 var expertIds = review.ReviewExperts.Select(o => o.Id); var expertUsers = await UserRepository.GetAll() .Include(o => o.Organization) .Include(o => o.Specialities) .Where(o => expertIds.Contains(o.Id)).ToListAsync(); //Logger.Error("Before ExpertTransform:" + DateTime.Now.ToLongTimeString()); var specialities = await SpecialityRepository.GetAllListAsync(); var reviewExpertDtos = expertUsers.Select(o => new ReviewExpertDto { Id = o.Id, Name = o.Name, OrganizationDisplayName = o.Organization?.DisplayName, Specialities = o.Specialities.Select(s => specialities.Single(sp => sp.Id == s.SpecialityId).Name).ToList() }); //var reviewExpertDtos = await UserAppService.UserToReviewExpertDtos(expertUsers,matchInstance.MatchId); //Logger.Error("After ExpertTransform:" + DateTime.Now.ToLongTimeString()); ViewBag.Experts = reviewExpertDtos; //获取对应的项目 var reviewProjects = review.ReviewProjects.OrderBy(o => o.Sort).ToList(); //Logger.Error("Before ProjectTransform:" + DateTime.Now.ToLongTimeString()); Logger.Error("0:" + DateTime.Now.ToString("HH:mm:ss:fff")); ViewBag.Projects = await ProjectAppService.ProjectToReviewProjectDtos(reviewProjects); //Logger.Error("After ProjectTransform:" + DateTime.Now.ToLongTimeString()); ViewData["MatchInstance"] = matchInstance; return(View(review)); }
public ProjectControllerTest() { // Auto Mapper Configurations var mappingConfig = new MapperConfiguration(mc => { mc.AddProfile(new MappingProfile()); }); mapper = mappingConfig.CreateMapper(); _mockRepo = new Mock <IRepository <Project> >(); _mockSystemRepo = new Mock <IRepository <SdlcSystem> >(); IProjectAppService _projectAppService = new ProjectAppService(_mockRepo.Object, mapper); ISdlcSystemAppService _sdlcSystemAppService = new SdlcSystemAppService(_mockSystemRepo.Object, mapper); _controller = new ProjectController(_projectAppService, _sdlcSystemAppService); _mockRepo.Setup(m => m.GetAll()) .Returns(Task.FromResult(MockData.Current.Projects.AsEnumerable())); _mockRepo.Setup(x => x.Save()).Returns(true); }
public async Task Test_local_database() { //Arange var mockServicelocalDatabase = new Mock <ILocalDatabaseRepository>(); var searchrepo = new Mock <ISearchRepository>().Object; var settingsRepo = new Mock <IClientIdSettingsRepository>().Object; var browserRepo = new Mock <IBrowserRepository>().Object; var shareRepo = new Mock <IShareRepository>().Object; List <DatabaseIdContent> dummyids = new List <DatabaseIdContent>() { new DatabaseIdContent() { id = "1" }, new DatabaseIdContent() { id = "2" }, new DatabaseIdContent() { id = "3" } }; mockServicelocalDatabase.Setup(m => m.GetTracksMySongs()).Returns(await Task.FromResult(dummyids)); var appService = new ProjectAppService(searchrepo, settingsRepo, mockServicelocalDatabase.Object, browserRepo, shareRepo); //Act var result = await appService.GetTracksMySongs(); //Assert Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(List <Track>)); }
public IndexModel(ProjectAppService projectAppService) { _projectAppService = projectAppService; }
public DetailsModel(ProjectAppService projectAppService) { _projectAppService = projectAppService; }
public WeatherForecastController(ILogger <WeatherForecastController> logger, ProjectAppService projectAppService) { _logger = logger; _projectAppService = projectAppService; }
public DetailsModel(ProjectAppService projectAppService, TaskAppService taskAppService) { _projectAppService = projectAppService; _taskAppService = taskAppService; }
public EditModel(ProjectAppService projectAppService) { _projectAppService = projectAppService; }
public DeleteModel(ProjectAppService projectAppService) { _projectAppService = projectAppService; }