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)); }
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>() }); }
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>() }; }