コード例 #1
0
        public async Task <IActionResult> AddArea(CreatePlanAreaServiceModel model)
        {
            var plan = await _planService.GetByIdAsync(model.PlanId);

            ValidateUser(plan.UserId);

            var result = await _planAreaService.CreatePlanAreaAsync(model);

            return(Json(result));
        }
コード例 #2
0
        public async Task <PlanAreaServiceModel> CreatePlanAreaAsync(CreatePlanAreaServiceModel model)
        {
            PlanArea planArea = new PlanArea
            {
                Name   = model.Name,
                PlanId = model.PlanId,
                UserId = model.UserId
            };
            await _planAreaObjectService.CreateAsync(planArea);

            return(new PlanAreaServiceModel
            {
                Id = planArea.Id,
                Name = planArea.Name,
                PlanId = planArea.PlanId,
                AreaTopics = Array.Empty <AreaTopicServiceModel>()
            });
        }
コード例 #3
0
        public async Task<PlanAreaServiceModel> CreatePlanAreaAsync(CreatePlanAreaServiceModel model)
        {
            PlanArea planArea = new PlanArea
            {
                Name = model.Name,
                PlanId = model.PlanId
            };
            await _planAreaWriteRepository.CreateAsync(planArea);

            await _planAreaWriteRepository.SaveChangesAsync();

            return new PlanAreaServiceModel
            {
                Id = planArea.Id,
                Name = planArea.Name,
                PlanId = planArea.PlanId,
                AreaTopics = Array.Empty<AreaTopicServiceModel>()
            };
        }