public async Task <AreaTopicResponseModel> CreateAreaTopicAsync(CreateAreaTopicServiceModel model) { var planArea = await _planAreaObjectService.GetByIdAsync <PlanArea>(model.PlanAreaId); AreaTopic areaTopic = new AreaTopic { PlanAreaId = model.PlanAreaId, PlanId = planArea.PlanId, UserId = planArea.UserId, Name = model.Name, Source = model.Source, Description = model.Description }; if (!model.IsTemplate && !string.IsNullOrEmpty(model.StartDate) && !string.IsNullOrEmpty(model.EndDate)) { areaTopic.StartDate = DateTime.ParseExact(model.StartDate, "yyyy-MM-dd", CultureInfo.CurrentCulture); areaTopic.EndDate = DateTime.ParseExact(model.EndDate, "yyyy-MM-dd", CultureInfo.CurrentCulture); } await _topicObjectService.CreateAsync(areaTopic); return(new AreaTopicResponseModel { Id = areaTopic.Id, Name = areaTopic.Name, PlanId = areaTopic.PlanId }); }
public async Task<AreaTopicResponseModel> CreateAreaTopicAsync(CreateAreaTopicServiceModel model) { var planArea = await _planAreaReadRepository.GetByIdAsync(model.PlanAreaId); AreaTopic areaTopic = new AreaTopic { PlanAreaId = model.PlanAreaId, PlanId = planArea.PlanId, Name = model.Name, StartDate = DateTime.ParseExact(model.StartDate, "yyyy-MM-dd", CultureInfo.CurrentCulture), EndDate = DateTime.ParseExact(model.EndDate, "yyyy-MM-dd", CultureInfo.CurrentCulture), Source = model.Source, Description = model.Description }; await _areaTopicRepository.CreateAsync(areaTopic); await _areaTopicRepository.SaveChangesAsync(); return new AreaTopicResponseModel { Id = areaTopic.Id, Name = areaTopic.Name, PlanId = areaTopic.PlanId }; }
public async Task DeleteAsync(string topicId) { AreaTopic topic = await _topicObjectService.GetByIdAsync <AreaTopic>(topicId); if (topic == null) { throw new DomainServicesException("Topic not found."); } await _topicObjectService.DeleteAsync(topic); }
public async Task DeleteAsync(string topicId) { AreaTopic topic = await _areaTopicReadRepository.GetByIdAsync(topicId); if (topic == null) { throw new DomainServicesException("Topic not found."); } await _areaTopicWriteRepository.DeleteAsync(topic); await _areaTopicWriteRepository.SaveChangesAsync(); }