private async Task <BaseResult> Update(Category category) { var result = new CreateOrUpdateResult() { Result = Result.Success }; var categoryForUpdation = CategoryRepository.Query().FirstOrDefault(l => l.Id == category.Id); if (categoryForUpdation == null) { result.Result = Result.Failed; result.Message = "Không tìm thấy danh mục"; return(result); } try { categoryForUpdation = category.ToCategory(categoryForUpdation); categoryForUpdation = categoryForUpdation.UpdateCommonInt(); await CategoryRepository.UpdateAsync(categoryForUpdation); } catch (Exception e) { result.Result = Result.SystemError; result.Message = e.ToString(); } result.Id = categoryForUpdation.Id; return(result); }
private async Task <BaseResult> Update(Comment comment) { var result = new CreateOrUpdateResult(); var commentForUpdate = CommentRepository.Query().FirstOrDefault(x => x.Id == comment.Id); if (commentForUpdate == null) { result.Result = Result.Failed; result.Message = "Không tìm thấy bình luận"; } else { try { commentForUpdate = comment.ToComment(commentForUpdate); await CommentRepository.UpdateAsync(commentForUpdate); } catch (Exception e) { result.Result = Result.SystemError; result.Message = e.ToString(); } } result.Id = commentForUpdate.Id; return(result); }
private async Task <BaseResult> Update(Lecture lecture) { var result = new CreateOrUpdateResult() { Result = Result.Success }; var lectureForUpdation = LectureRepository.Query().FirstOrDefault(l => l.Id == lecture.Id); if (lectureForUpdation == null) { result.Result = Result.Failed; result.Message = "Không tìm thấy bài giảng"; return(result); } try { lectureForUpdation = lecture.ToLecture(lectureForUpdation); lectureForUpdation = lectureForUpdation.UpdateCommonInt(); await LectureRepository.UpdateAsync(lectureForUpdation); } catch (Exception e) { result.Result = Result.SystemError; result.Message = e.ToString(); } result.Id = lectureForUpdation.Id; return(result); }
private async Task <BaseResult> Create(Comment comment) { var result = new CreateOrUpdateResult(); try { await CommentRepository.InsertAsync(comment); } catch (Exception e) { result.Result = Result.SystemError; result.Message = e.ToString(); return(result); } result.Id = comment.Id; return(result); }
private async Task <BaseResult> Create(Category category) { var result = new CreateOrUpdateResult() { Result = Result.Success }; category.Name = category.Name.Trim(); try { await CategoryRepository.InsertAsync(category); } catch (Exception e) { result.Result = Result.SystemError; result.Message = e.ToString(); return(result); } result.Id = category.Id; return(result); }
private async Task <BaseResult> Create(Lecture lecture) { var result = new CreateOrUpdateResult() { Result = Result.Success }; lecture.Name = lecture.Name.Trim(); try { await LectureRepository.InsertAsync(lecture); } catch (Exception e) { result.Result = Result.SystemError; result.Message = e.ToString(); return(result); } result.Id = lecture.Id; return(result); }
/// <summary> /// Initializes a new <see cref="RawResult"/>. /// </summary> /// <param name="userId">User identifier.</param> /// <param name="result">Operation result.</param> public RawResult(int userId, CreateOrUpdateResult result) { UserId = userId; Result = result; }