public async Task Update(AreaTopicServiceModel model) { var topic = await _topicService.GetByIdAsync(model.Id); ValidateUser(topic.UserId); await _topicService.UpdateAsync(model); }
public async Task UpdateAsync(AreaTopicServiceModel model) { using (_unitOfWork) { var topic = await _areaTopicReadRepository.GetByIdAsync(model.Id); if (topic == null) { throw new DomainServicesException("Topic not found."); } topic.Name = model.Name; topic.StartDate = DateTime.ParseExact(model.StartDate, "yyyy-MM-dd", CultureInfo.CurrentCulture); topic.EndDate = DateTime.ParseExact(model.EndDate, "yyyy-MM-dd", CultureInfo.CurrentCulture); topic.Source = model.Source; topic.Description = model.Description; await _unitOfWork.CommitAsync(); } }
public async Task UpdateAsync(AreaTopicServiceModel model) { var topic = await _topicObjectService.GetByIdAsync <AreaTopic>(model.Id); if (topic == null) { throw new DomainServicesException("Topic not found."); } topic.Name = model.Name; if (!model.IsTemplate && !string.IsNullOrEmpty(model.StartDate) && !string.IsNullOrEmpty(model.EndDate)) { topic.StartDate = DateTime.ParseExact(model.StartDate, "yyyy-MM-dd", CultureInfo.CurrentCulture); topic.EndDate = DateTime.ParseExact(model.EndDate, "yyyy-MM-dd", CultureInfo.CurrentCulture); } topic.Source = model.Source; topic.Description = model.Description; await _topicObjectService.UpdateAsync(topic); }