コード例 #1
0
        public ActionResult <CourseCommentCategoryAddViewModel> AddCourseCommentCategory(CourseCommentCategoryAddViewModel courseCommentCategoryAddViewModel)
        {
            CourseCommentCategoryAddViewModel courseCommentAdd = new CourseCommentCategoryAddViewModel();

            try
            {
                courseCommentAdd = _reportCardService.SaveCourseCommentCategory(courseCommentCategoryAddViewModel);
            }
            catch (Exception ex)
            {
                courseCommentAdd._message = ex.Message;
                courseCommentAdd._failure = true;
            }
            return(courseCommentAdd);
        }
コード例 #2
0
        /// <summary>
        /// Add Report Card Comments
        /// </summary>
        /// <param name="reportCardViewModel"></param>
        /// <returns></returns>

        //public ReportCardCommentsAddViewModel AddReportCardComments(ReportCardCommentsAddViewModel reportCardCommentsAddViewModel)
        //{
        //    ReportCardCommentsAddViewModel reportCardCommentsAdd = new ReportCardCommentsAddViewModel();
        //    if(TokenManager.CheckToken(reportCardCommentsAddViewModel._tenantName + reportCardCommentsAddViewModel._userName, reportCardCommentsAddViewModel._token))
        //    {
        //        reportCardCommentsAdd = this.reportCardRepository.AddReportCardComments(reportCardCommentsAddViewModel);
        //    }
        //    else
        //    {
        //        reportCardCommentsAdd._message= TOKENINVALID;
        //        reportCardCommentsAdd._failure = true;
        //    }

        //    return reportCardCommentsAdd;
        //}

        /// <summary>
        /// Update Report Card Comments
        /// </summary>
        /// <param name="reportCardViewModel"></param>
        /// <returns></returns>

        //public ReportCardCommentsAddViewModel UpdateReportCardComments(ReportCardCommentsAddViewModel reportCardCommentsAddViewModel)
        //{
        //    ReportCardCommentsAddViewModel reportCardCommentsUpdate = new ReportCardCommentsAddViewModel();
        //    if (TokenManager.CheckToken(reportCardCommentsAddViewModel._tenantName + reportCardCommentsAddViewModel._userName, reportCardCommentsAddViewModel._token))
        //    {
        //        reportCardCommentsUpdate = this.reportCardRepository.UpdateReportCardComments(reportCardCommentsAddViewModel);
        //    }
        //    else
        //    {
        //        reportCardCommentsUpdate._message = TOKENINVALID;
        //        reportCardCommentsUpdate._failure = true;
        //    }
        //    return reportCardCommentsUpdate;
        //}

        /// <summary>
        /// Delete Report Card Comments
        /// </summary>
        /// <param name="reportCardViewModel"></param>
        /// <returns></returns>
        //public ReportCardCommentsAddViewModel DeleteReportCardComments(ReportCardCommentsAddViewModel reportCardCommentsAddViewModel)
        //{
        //    ReportCardCommentsAddViewModel reportCardCommentsDelete = new ReportCardCommentsAddViewModel();
        //    if (TokenManager.CheckToken(reportCardCommentsAddViewModel._tenantName + reportCardCommentsAddViewModel._userName, reportCardCommentsAddViewModel._token))
        //    {
        //        reportCardCommentsDelete = this.reportCardRepository.DeleteReportCardComments(reportCardCommentsAddViewModel);
        //    }
        //    else
        //    {
        //        reportCardCommentsDelete._message = TOKENINVALID;
        //        reportCardCommentsDelete._failure = true;
        //    }

        //    return reportCardCommentsDelete;
        //}

        /// <summary>
        /// Add Course Comment Category
        /// </summary>
        /// <param name="courseCommentCategoryAddViewModel"></param>
        /// <returns></returns>

        public CourseCommentCategoryAddViewModel SaveCourseCommentCategory(CourseCommentCategoryAddViewModel courseCommentCategoryAddViewModel)
        {
            CourseCommentCategoryAddViewModel courseCommentcategoryAdd = new CourseCommentCategoryAddViewModel();

            if (TokenManager.CheckToken(courseCommentCategoryAddViewModel._tenantName + courseCommentCategoryAddViewModel._userName, courseCommentCategoryAddViewModel._token))
            {
                courseCommentcategoryAdd = this.reportCardRepository.AddCourseCommentCategory(courseCommentCategoryAddViewModel);
            }
            else
            {
                courseCommentcategoryAdd._message = TOKENINVALID;
                courseCommentcategoryAdd._failure = true;
            }

            return(courseCommentcategoryAdd);
        }
コード例 #3
0
        /// <summary>
        /// Add Report Card Comments
        /// </summary>
        /// <param name="reportCardViewModel"></param>
        /// <returns></returns>

        //public ReportCardCommentsAddViewModel AddReportCardComments(ReportCardCommentsAddViewModel reportCardCommentsAddViewModel)
        //{
        //    using (var transaction = this.context.Database.BeginTransaction())
        //    {
        //        try
        //        {
        //            List<ReportCardComments> reportCardComments = new List<ReportCardComments>();

        //            int? id = 1;
        //            int? SortOrder = 1;

        //            if (reportCardCommentsAddViewModel.reportCardComments.Count > 0)
        //            {
        //                //var reportCardCommentData = this.context?.ReportCardComments.Where(x => x.TenantId == reportCardCommentsAddViewModel.TenantId && x.SchoolId == reportCardCommentsAddViewModel.SchoolId).OrderByDescending(x => x.Id).FirstOrDefault();

        //                //if (reportCardCommentData != null)
        //                //{
        //                //    id = Convert.ToInt32(reportCardCommentData.Id) + 1;
        //                //}

        //                //var reportCardCommentSortOrder = this.context?.ReportCardComments.Where(x => x.TenantId == reportCardCommentsAddViewModel.TenantId && x.SchoolId == reportCardCommentsAddViewModel.SchoolId && x.CourseCommentId == reportCardCommentsAddViewModel.CourseCommentId).OrderByDescending(x => x.Id).FirstOrDefault();

        //                //if (reportCardCommentSortOrder != null)
        //                //{
        //                //    SortOrder = reportCardCommentSortOrder.SortOrder + 1;
        //                //}

        //                //foreach (var reportComment in reportCardCommentsAddViewModel.reportCardComments.ToList())
        //                //{

        //                //    reportComment.TenantId = reportCardCommentsAddViewModel.TenantId;
        //                //    reportComment.SchoolId = reportCardCommentsAddViewModel.SchoolId;
        //                //    reportComment.CourseCommentId = reportCardCommentsAddViewModel.CourseCommentId;
        //                //    reportComment.CourseId = 1;
        //                //    reportComment.CourseSectionId = 1;
        //                //    reportComment.SortOrder = SortOrder;
        //                //    reportComment.Id = id;
        //                //    reportComment.CreatedOn = DateTime.UtcNow;
        //                //    reportCardComments.Add(reportComment);
        //                //    id++;
        //                //    SortOrder++;
        //                //}
        //                //reportCardCommentsAddViewModel._message = "Report Comments added succsesfully.";

        //                //this.context?.ReportCardComments.AddRange(reportCardComments);
        //                //this.context?.SaveChanges();
        //                //transaction.Commit();
        //                //reportCardCommentsAddViewModel._failure = false;
        //            }
        //        }
        //        catch (Exception ex)
        //        {
        //            transaction.Rollback();
        //            reportCardCommentsAddViewModel._failure = true;
        //            reportCardCommentsAddViewModel._message = ex.Message;
        //        }
        //        return reportCardCommentsAddViewModel;
        //    }
        //}

        ///// <summary>
        ///// Update Report Card Comments
        ///// </summary>
        ///// <param name="reportCardViewModel"></param>
        ///// <returns></returns>

        //public ReportCardCommentsAddViewModel UpdateReportCardComments(ReportCardCommentsAddViewModel reportCardCommentsAddViewModel)
        //{
        //    try
        //    {
        //        List<ReportCardComments> reportCardComments = new List<ReportCardComments>();

        //        if (reportCardCommentsAddViewModel.reportCardComments.Count > 0)
        //        {
        //           /* var reportCommentDataExist = this.context?.ReportCardComments.Where(x => x.TenantId == reportCardCommentsAddViewModel.TenantId && x.SchoolId == reportCardCommentsAddViewModel.SchoolId && x.CourseCommentId == reportCardCommentsAddViewModel.CourseCommentId).ToList();

        //            if (reportCommentDataExist.Count > 0)
        //            {
        //                this.context?.ReportCardComments.RemoveRange(reportCommentDataExist);
        //                this.context?.SaveChanges();
        //            }

        //            int? id = 1;
        //            int? SortOrder = 1;

        //            var reportCardCommentData = this.context?.ReportCardComments.Where(x => x.TenantId == reportCardCommentsAddViewModel.TenantId && x.SchoolId == reportCardCommentsAddViewModel.SchoolId).OrderByDescending(x => x.Id).FirstOrDefault();

        //            if (reportCardCommentData != null)
        //            {
        //                id = Convert.ToInt32(reportCardCommentData.Id) + 1;
        //            }

        //            var reportCardCommentSortOrder = this.context?.ReportCardComments.Where(x => x.TenantId == reportCardCommentsAddViewModel.TenantId && x.SchoolId == reportCardCommentsAddViewModel.SchoolId && x.CourseCommentId == reportCardCommentsAddViewModel.CourseCommentId).OrderByDescending(x => x.SortOrder).FirstOrDefault();

        //            if (reportCardCommentSortOrder != null)
        //            {
        //                SortOrder = reportCardCommentSortOrder.SortOrder + 1;
        //            }

        //            foreach (var reportComment in reportCardCommentsAddViewModel.reportCardComments.ToList())
        //            {

        //                reportComment.TenantId = reportCardCommentsAddViewModel.TenantId;
        //                reportComment.SchoolId = reportCardCommentsAddViewModel.SchoolId;
        //                reportComment.CourseCommentId = reportCardCommentsAddViewModel.CourseCommentId;
        //                reportComment.CourseId = 1;
        //                reportComment.CourseSectionId = 1;

        //                reportComment.SortOrder = SortOrder;
        //                reportComment.Id = id;
        //                reportComment.UpdatedOn = DateTime.UtcNow;
        //                reportCardComments.Add(reportComment);
        //                id++;
        //                SortOrder++;
        //            }
        //            reportCardCommentsAddViewModel._message = "Report Comments Updated succsesfully.";

        //            this.context?.ReportCardComments.AddRange(reportCardComments);
        //            this.context?.SaveChanges();
        //            //transaction.Commit();
        //            reportCardCommentsAddViewModel._failure = false;*/
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        //transaction.Rollback();
        //        reportCardCommentsAddViewModel._failure = true;
        //        reportCardCommentsAddViewModel._message = ex.Message;
        //    }
        //    return reportCardCommentsAddViewModel;
        //}

        ///// <summary>
        ///// Delete Report Card Comments
        ///// </summary>
        ///// <param name="reportCardViewModel"></param>
        ///// <returns></returns>
        //public ReportCardCommentsAddViewModel DeleteReportCardComments(ReportCardCommentsAddViewModel reportCardCommentsAddViewModel)
        //{
        //    try
        //    {
        //       /* if (reportCardCommentsAddViewModel.reportCardComments.Count > 0)
        //        {
        //            var reportCardCommentDataExist = this.context?.ReportCardComments.FirstOrDefault(x => x.TenantId == reportCardCommentsAddViewModel.TenantId && x.SchoolId == reportCardCommentsAddViewModel.SchoolId && x.Id == reportCardCommentsAddViewModel.reportCardComments.FirstOrDefault().Id && x.CourseCommentId == reportCardCommentsAddViewModel.CourseCommentId);

        //            if (reportCardCommentDataExist != null)
        //            {
        //                this.context?.ReportCardComments.Remove(reportCardCommentDataExist);
        //                this.context?.SaveChanges();
        //                reportCardCommentsAddViewModel._failure = false;
        //                reportCardCommentsAddViewModel._message = "Deleted Successfully";
        //            }
        //            else
        //            {
        //                reportCardCommentsAddViewModel._failure = true;
        //                reportCardCommentsAddViewModel._message = NORECORDFOUND;
        //            }
        //        }*/
        //    }
        //    catch (Exception ex)
        //    {
        //        reportCardCommentsAddViewModel._failure = true;
        //        reportCardCommentsAddViewModel._message = ex.Message;
        //    }
        //    return reportCardCommentsAddViewModel;
        //}


        /// <summary>
        /// Add Course Comment Category
        /// </summary>
        /// <param name="courseCommentCategoryAddViewModel"></param>
        /// <returns></returns>

        public CourseCommentCategoryAddViewModel AddCourseCommentCategory(CourseCommentCategoryAddViewModel courseCommentCategoryAddViewModel)
        {
            try
            {
                List<CourseCommentCategory> courseCommentCategoryList = new List<CourseCommentCategory>();
                int i = 0;
                var distinctCourseData = courseCommentCategoryAddViewModel.courseCommentCategory.Select(s => new { s.CourseId, s.TenantId, s.SchoolId }).Distinct().ToList();

                int? courseCommentId = 1;

                foreach (var course in distinctCourseData.ToList())
                {
                    var courseCommentCategoryDataExist = this.context?.CourseCommentCategory.Where(x => x.TenantId == course.TenantId && x.SchoolId == course.SchoolId && x.CourseId == course.CourseId).ToList();

                    if (courseCommentCategoryDataExist.Count > 0)
                    {
                        this.context?.CourseCommentCategory.RemoveRange(courseCommentCategoryDataExist);
                        this.context?.SaveChanges();
                    }

                    var courseCommentCategoryData = courseCommentCategoryAddViewModel.courseCommentCategory.Where(x => x.CourseId == course.CourseId).ToList();

                    int? sortOrder = 1;
                    int? sortOrderForAllCourse = 1;

                    if (i == 0)
                    {
                        var courseCommentCategoryDataForID = this.context?.CourseCommentCategory.Where(x => x.TenantId == course.TenantId && x.SchoolId == course.SchoolId).OrderByDescending(x => x.CourseCommentId).FirstOrDefault();

                        if (courseCommentCategoryDataForID != null)
                        {
                            courseCommentId = courseCommentCategoryDataForID.CourseCommentId + 1;
                        }
                    }

                    foreach (var courseCommentCategory in courseCommentCategoryData)
                    {
                        courseCommentCategory.CourseCommentId = (int)courseCommentId;
                        courseCommentCategory.SortOrder = courseCommentCategory.CourseId != null ? sortOrder : sortOrderForAllCourse;
                        courseCommentCategory.CreatedOn = DateTime.UtcNow;
                        courseCommentCategoryList.Add(courseCommentCategory);
                        courseCommentId++;
                        sortOrder++;
                        sortOrderForAllCourse++;
                    }
                    i++;
                }

                this.context?.CourseCommentCategory.AddRange(courseCommentCategoryList);
                this.context?.SaveChanges();
                courseCommentCategoryAddViewModel._failure = false;
                courseCommentCategoryAddViewModel._message = "Course Comment Category Added Successfully";

            }
            catch (Exception es)
            {
                courseCommentCategoryAddViewModel._message = es.Message;
                courseCommentCategoryAddViewModel._failure = true;
            }
            return courseCommentCategoryAddViewModel;
        }