public async Task <IActionResult> UpdateCourseAsync([FromBody] UpdateCourseRequestDto request) { var CourseBiz = new CourseBiz(); var contentBiz = new RichtextBiz(); var CourseModel = await CourseBiz.GetAsync(request.CourseGuid); if (CourseModel == null) { return(Failed(ErrorCode.DataBaseError, "数据错误")); } var richtextModel = await contentBiz.GetAsync(CourseModel.ContentGuid); richtextModel.Content = request.Content; richtextModel.LastUpdatedBy = UserID; richtextModel.LastUpdatedDate = DateTime.Now; richtextModel.OrgGuid = string.Empty; richtextModel.OwnerGuid = request.CourseGuid; CourseModel.Summary = request.Abstract; CourseModel.LastUpdatedBy = UserID; CourseModel.LastUpdatedDate = DateTime.Now; CourseModel.Title = request.Title; CourseModel.Visible = request.Visible; CourseModel.Enable = request.Enable; CourseModel.LogoGuid = request.PictureGuid; var response = await new CourseBiz().UpdateAsync(richtextModel, CourseModel); if (!response) { return(Failed(ErrorCode.DataBaseError, "修改失败")); } return(Success(response)); }
public async Task <IActionResult> GetCourseInfoAsync([FromBody] GetCourseInfoRequestDto request) { var courseBiz = new CourseBiz(); var contentBiz = new RichtextBiz(); AccessoryBiz accessoryBiz = new AccessoryBiz(); var courseModel = await courseBiz.GetAsync(request.CourseGuid); if (courseModel == null) { return(Failed(ErrorCode.DataBaseError, "数据错误")); } var richtextModel = await contentBiz.GetAsync(courseModel.ContentGuid); var accessory = await accessoryBiz.GetAsync(courseModel.LogoGuid); return(Success(new GetCourseInfoResponseDto { Abstract = courseModel.Summary, Content = richtextModel.Content, PictureGuid = courseModel.LogoGuid, Title = courseModel.Title, Visible = courseModel.Visible, Enable = courseModel.Enable, PictureUrl = $"{accessory?.BasePath}{accessory?.RelativePath}", CourseGuid = courseModel.CourseGuid })); }
public async Task <IActionResult> SetCourseVisibleAsync([FromBody] SetCourseVisibleRequestDto request) { var courseBiz = new CourseBiz(); var CourseModel = await courseBiz.GetAsync(request.CourseGuid); if (CourseModel == null) { return(Failed(ErrorCode.DataBaseError, "数据错误")); } CourseModel.Visible = request.Visible; var response = await courseBiz.UpdateAsync(CourseModel); if (!response) { return(Failed(ErrorCode.DataBaseError, "跟新失败")); } return(Success()); }
public async Task <IActionResult> DisableEnableCourseAsync([FromBody] DisableEnableCourseRequestDto request) { var courseBiz = new CourseBiz(); var entity = await courseBiz.GetAsync(request.Guid); if (entity == null) { return(Failed(ErrorCode.UserData, "找不到数据")); } entity.LastUpdatedBy = UserID; entity.LastUpdatedDate = DateTime.Now; entity.Enable = request.Enable; var result = await courseBiz.UpdateAsync(entity); if (!result) { return(Failed(ErrorCode.UserData, "修改失败")); } return(Success()); }