示例#1
0
        public virtual async Task <long> CreateProblemSolution(CreateSolutionInput input)
        {
            var problem = ObjectMapper.Map <Problem>(input);

            problem.Types = new List <ProblemToType>();
            var article = ObjectMapper.Map <Article.Article>(input);

            var solution = new ProblemSolution
            {
                Problem  = problem,
                Solution = article,
            };

            var pId = await _problemSolutionManager.Create(solution);

            foreach (var tid in input.TypeIds)
            {
                problem.Types.Add(new ProblemToType
                {
                    ProblemId     = pId,
                    ProblemTypeId = tid,
                });
            }

            return(pId);
        }
示例#2
0
 private GetAllProblemSolutionList SolutionToDto(ProblemSolution solution)
 {
     return(new GetAllProblemSolutionList
     {
         Id = solution.Id,
         ProblemName = solution.Problem.Name,
         ProblemUrl = solution.Problem.Url,
         ArticleTitle = solution.Solution.Title,
         CreatorUserId = solution.CreatorUserId ?? AppConsts.FallBackUserId,
         CreationTime = solution.CreationTime,
         ProblemTypes = solution.Problem.Types.Select(t =>
                                                      ObjectMapper.Map <ProblemTypeDto>(
                                                          _problemTypeManager.Get(t.ProblemTypeId).Result))
     });
 }