示例#1
0
        /// <summary>
        /// Add StudentEnrollmentCode
        /// </summary>
        /// <param name="studentEnrollmentCodeAddViewModel"></param>
        /// <returns></returns>

        public StudentEnrollmentCodeAddViewModel AddStudentEnrollmentCode(StudentEnrollmentCodeAddViewModel studentEnrollmentCodeAddViewModel)
        {
            //int? MasterEnrollmentCode = Utility.GetMaxPK(this.context, new Func<StudentEnrollmentCode, int>(x => x.EnrollmentCode));

            int?MasterEnrollmentCode = 1;

            var EnrollmentCodeData = this.context?.StudentEnrollmentCode.Where(x => x.SchoolId == studentEnrollmentCodeAddViewModel.studentEnrollmentCode.SchoolId && x.TenantId == studentEnrollmentCodeAddViewModel.studentEnrollmentCode.TenantId).OrderByDescending(x => x.EnrollmentCode).FirstOrDefault();

            if (EnrollmentCodeData != null)
            {
                MasterEnrollmentCode = EnrollmentCodeData.EnrollmentCode + 1;
            }

            studentEnrollmentCodeAddViewModel.studentEnrollmentCode.EnrollmentCode = (int)MasterEnrollmentCode;

            var studentEnrollmentCodeData = this.context?.StudentEnrollmentCode.Where(x => x.TenantId == studentEnrollmentCodeAddViewModel.studentEnrollmentCode.TenantId && x.SchoolId == studentEnrollmentCodeAddViewModel.studentEnrollmentCode.SchoolId && x.Type.ToLower() == studentEnrollmentCodeAddViewModel.studentEnrollmentCode.Type.ToLower() && x.Type.ToLower() != "DROP".ToLower() && x.Type.ToLower() != "Add".ToLower()).ToList();

            if (studentEnrollmentCodeData.Count > 0)
            {
                studentEnrollmentCodeAddViewModel._failure = true;
                studentEnrollmentCodeAddViewModel._message = "You can't add any enrollment code in this type";
                return(studentEnrollmentCodeAddViewModel);
            }
            studentEnrollmentCodeAddViewModel.studentEnrollmentCode.LastUpdated = DateTime.UtcNow;
            this.context?.StudentEnrollmentCode.Add(studentEnrollmentCodeAddViewModel.studentEnrollmentCode);
            this.context?.SaveChanges();
            studentEnrollmentCodeAddViewModel._failure = false;
            studentEnrollmentCodeAddViewModel._message = "Enrollment Code Added Successfully";

            return(studentEnrollmentCodeAddViewModel);
        }
示例#2
0
        /// <summary>
        /// Update StudentEnrollmentCode
        /// </summary>
        /// <param name="studentEnrollmentCodeAddViewModel"></param>
        /// <returns></returns>
        public StudentEnrollmentCodeAddViewModel UpdateStudentEnrollmentCode(StudentEnrollmentCodeAddViewModel studentEnrollmentCodeAddViewModel)
        {
            try
            {
                var studentEnrollmentCodeUpdate = this.context?.StudentEnrollmentCode.FirstOrDefault(x => x.TenantId == studentEnrollmentCodeAddViewModel.studentEnrollmentCode.TenantId && x.SchoolId == studentEnrollmentCodeAddViewModel.studentEnrollmentCode.SchoolId && x.EnrollmentCode == studentEnrollmentCodeAddViewModel.studentEnrollmentCode.EnrollmentCode);

                studentEnrollmentCodeUpdate.TenantId       = studentEnrollmentCodeAddViewModel.studentEnrollmentCode.TenantId;
                studentEnrollmentCodeUpdate.SchoolId       = studentEnrollmentCodeAddViewModel.studentEnrollmentCode.SchoolId;
                studentEnrollmentCodeUpdate.EnrollmentCode = studentEnrollmentCodeAddViewModel.studentEnrollmentCode.EnrollmentCode;
                studentEnrollmentCodeUpdate.AcademicYear   = studentEnrollmentCodeAddViewModel.studentEnrollmentCode.AcademicYear;
                studentEnrollmentCodeUpdate.Title          = studentEnrollmentCodeAddViewModel.studentEnrollmentCode.Title;
                studentEnrollmentCodeUpdate.ShortName      = studentEnrollmentCodeAddViewModel.studentEnrollmentCode.ShortName;
                studentEnrollmentCodeUpdate.SortOrder      = studentEnrollmentCodeAddViewModel.studentEnrollmentCode.SortOrder;
                studentEnrollmentCodeUpdate.Type           = studentEnrollmentCodeAddViewModel.studentEnrollmentCode.Type;
                studentEnrollmentCodeUpdate.LastUpdated    = DateTime.UtcNow;
                studentEnrollmentCodeUpdate.UpdatedBy      = studentEnrollmentCodeAddViewModel.studentEnrollmentCode.UpdatedBy;

                this.context?.SaveChanges();

                studentEnrollmentCodeAddViewModel._failure = false;
            }
            catch (Exception ex)
            {
                studentEnrollmentCodeAddViewModel.studentEnrollmentCode = null;
                studentEnrollmentCodeAddViewModel._failure = true;
                studentEnrollmentCodeAddViewModel._message = ex.Message;
            }
            return(studentEnrollmentCodeAddViewModel);
        }
示例#3
0
        /// <summary>
        /// Add StudentEnrollmentCode
        /// </summary>
        /// <param name="studentEnrollmentCodeAddViewModel"></param>
        /// <returns></returns>

        public StudentEnrollmentCodeAddViewModel AddStudentEnrollmentCode(StudentEnrollmentCodeAddViewModel studentEnrollmentCodeAddViewModel)
        {
            int?MasterEnrollmentCode = Utility.GetMaxPK(this.context, new Func <StudentEnrollmentCode, int>(x => x.EnrollmentCode));

            studentEnrollmentCodeAddViewModel.studentEnrollmentCode.EnrollmentCode = (int)MasterEnrollmentCode;

            studentEnrollmentCodeAddViewModel.studentEnrollmentCode.LastUpdated = DateTime.UtcNow;
            this.context?.StudentEnrollmentCode.Add(studentEnrollmentCodeAddViewModel.studentEnrollmentCode);
            this.context?.SaveChanges();
            studentEnrollmentCodeAddViewModel._failure = false;
            return(studentEnrollmentCodeAddViewModel);
        }
        public ActionResult <StudentEnrollmentCodeAddViewModel> UpdateStudentEnrollmentCode(StudentEnrollmentCodeAddViewModel studentEnrollmentCodeAddViewModel)
        {
            StudentEnrollmentCodeAddViewModel studentEnrollmentCodeUpdate = new StudentEnrollmentCodeAddViewModel();

            try
            {
                studentEnrollmentCodeUpdate = _studentEnrollmentCodeService.UpdateStudentEnrollmentCode(studentEnrollmentCodeAddViewModel);
            }
            catch (Exception es)
            {
                studentEnrollmentCodeUpdate._failure = true;
                studentEnrollmentCodeUpdate._message = es.Message;
            }
            return(studentEnrollmentCodeUpdate);
        }
示例#5
0
        /// <summary>
        /// Update StudentEnrollmentCode
        /// </summary>
        /// <param name="studentEnrollmentCodeAddViewModel"></param>
        /// <returns></returns>
        public StudentEnrollmentCodeAddViewModel UpdateStudentEnrollmentCode(StudentEnrollmentCodeAddViewModel studentEnrollmentCodeAddViewModel)
        {
            StudentEnrollmentCodeAddViewModel studentEnrollmentCodeUpdate = new StudentEnrollmentCodeAddViewModel();

            if (TokenManager.CheckToken(studentEnrollmentCodeAddViewModel._tenantName, studentEnrollmentCodeAddViewModel._token))
            {
                studentEnrollmentCodeUpdate = this.studentEnrollmentCodeRepository.UpdateStudentEnrollmentCode(studentEnrollmentCodeAddViewModel);
            }
            else
            {
                studentEnrollmentCodeUpdate._failure = true;
                studentEnrollmentCodeUpdate._message = TOKENINVALID;
            }
            return(studentEnrollmentCodeUpdate);
        }
示例#6
0
        /// <summary>
        /// Update StudentEnrollmentCode
        /// </summary>
        /// <param name="studentEnrollmentCodeAddViewModel"></param>
        /// <returns></returns>
        public StudentEnrollmentCodeAddViewModel UpdateStudentEnrollmentCode(StudentEnrollmentCodeAddViewModel studentEnrollmentCodeAddViewModel)
        {
            try
            {
                var studentEnrollmentCodeUpdate = this.context?.StudentEnrollmentCode.FirstOrDefault(x => x.TenantId == studentEnrollmentCodeAddViewModel.studentEnrollmentCode.TenantId && x.SchoolId == studentEnrollmentCodeAddViewModel.studentEnrollmentCode.SchoolId && x.EnrollmentCode == studentEnrollmentCodeAddViewModel.studentEnrollmentCode.EnrollmentCode);

                var sameTitleExits = this.context?.StudentEnrollment.Where(x => x.SchoolId == studentEnrollmentCodeUpdate.SchoolId && x.TenantId == studentEnrollmentCodeUpdate.TenantId && (x.EnrollmentCode.ToLower() == studentEnrollmentCodeUpdate.Title.ToLower() || x.ExitCode.ToLower() == studentEnrollmentCodeUpdate.Title.ToLower())).ToList();
                if (sameTitleExits.Count > 0)
                {
                    foreach (var title in sameTitleExits)
                    {
                        if (title.EnrollmentCode != null && title.EnrollmentCode.ToLower() == studentEnrollmentCodeUpdate.Title.ToLower())
                        {
                            title.EnrollmentCode = studentEnrollmentCodeAddViewModel.studentEnrollmentCode.Title;
                        }
                        if (title.ExitCode != null && title.ExitCode.ToLower() == studentEnrollmentCodeUpdate.Title.ToLower())
                        {
                            title.ExitCode = studentEnrollmentCodeAddViewModel.studentEnrollmentCode.Title;
                        }
                    }
                    this.context?.StudentEnrollment.UpdateRange(sameTitleExits);
                }

                if (studentEnrollmentCodeAddViewModel.studentEnrollmentCode.Type.ToLower() != studentEnrollmentCodeUpdate.Type.ToLower())
                {
                    studentEnrollmentCodeAddViewModel._message = "Can't edit Type because it is not editable";
                }
                else
                {
                    studentEnrollmentCodeAddViewModel.studentEnrollmentCode.LastUpdated = DateTime.UtcNow;
                    this.context.Entry(studentEnrollmentCodeUpdate).CurrentValues.SetValues(studentEnrollmentCodeAddViewModel.studentEnrollmentCode);
                    this.context?.SaveChanges();
                    studentEnrollmentCodeAddViewModel._failure = false;
                    studentEnrollmentCodeAddViewModel._message = "Enrollment Code Updated Successfully";
                }
            }
            catch (Exception ex)
            {
                studentEnrollmentCodeAddViewModel.studentEnrollmentCode = null;
                studentEnrollmentCodeAddViewModel._failure = true;
                studentEnrollmentCodeAddViewModel._message = ex.Message;
            }
            return(studentEnrollmentCodeAddViewModel);
        }
示例#7
0
        /// <summary>
        /// Delete StudentEnrollmentCode
        /// </summary>
        /// <param name="studentEnrollmentCodeAddViewModel"></param>
        /// <returns></returns>

        public StudentEnrollmentCodeAddViewModel DeleteStudentEnrollmentCode(StudentEnrollmentCodeAddViewModel studentEnrollmentCodeAddViewModel)
        {
            try
            {
                var studentEnrollmentCodeDelete = this.context?.StudentEnrollmentCode.FirstOrDefault(x => x.TenantId == studentEnrollmentCodeAddViewModel.studentEnrollmentCode.TenantId && x.SchoolId == studentEnrollmentCodeAddViewModel.studentEnrollmentCode.SchoolId && x.EnrollmentCode == studentEnrollmentCodeAddViewModel.studentEnrollmentCode.EnrollmentCode);

                this.context?.StudentEnrollmentCode.Remove(studentEnrollmentCodeDelete);
                this.context?.SaveChanges();
                studentEnrollmentCodeAddViewModel._failure = false;
                studentEnrollmentCodeAddViewModel._message = "Deleted";
            }

            catch (Exception es)
            {
                studentEnrollmentCodeAddViewModel._failure = true;
                studentEnrollmentCodeAddViewModel._message = es.Message;
            }
            return(studentEnrollmentCodeAddViewModel);
        }
示例#8
0
        /// <summary>
        /// Delete StudentEnrollmentCode
        /// </summary>
        /// <param name="studentEnrollmentCodeAddViewModel"></param>
        /// <returns></returns>

        public StudentEnrollmentCodeAddViewModel DeleteStudentEnrollmentCode(StudentEnrollmentCodeAddViewModel studentEnrollmentCodeAddViewModel)
        {
            try
            {
                var studentEnrollmentCodeDelete = this.context?.StudentEnrollmentCode.FirstOrDefault(x => x.TenantId == studentEnrollmentCodeAddViewModel.studentEnrollmentCode.TenantId && x.SchoolId == studentEnrollmentCodeAddViewModel.studentEnrollmentCode.SchoolId && x.EnrollmentCode == studentEnrollmentCodeAddViewModel.studentEnrollmentCode.EnrollmentCode);

                if (studentEnrollmentCodeDelete != null)
                {
                    if (studentEnrollmentCodeDelete.Type.ToLower() == "Roll over".ToLower() || studentEnrollmentCodeDelete.Type.ToLower() == "Enroll (Transfer)".ToLower() || studentEnrollmentCodeDelete.Type.ToLower() == "Drop (Transfer)".ToLower())
                    {
                        studentEnrollmentCodeAddViewModel._failure = true;
                        studentEnrollmentCodeAddViewModel._message = "Cannot delete because it is not deletable.";
                    }
                    else
                    {
                        var studentEnrollmentExits = this.context?.StudentEnrollment.FirstOrDefault(x => x.TenantId == studentEnrollmentCodeDelete.TenantId && x.SchoolId == studentEnrollmentCodeDelete.SchoolId && (x.EnrollmentCode == studentEnrollmentCodeDelete.Title || x.ExitCode == studentEnrollmentCodeDelete.Title));
                        if (studentEnrollmentExits != null)
                        {
                            studentEnrollmentCodeAddViewModel._failure = true;
                            studentEnrollmentCodeAddViewModel._message = "Cannot delete because enrollment codes are associated.";
                        }
                        else
                        {
                            this.context?.StudentEnrollmentCode.Remove(studentEnrollmentCodeDelete);
                            this.context?.SaveChanges();
                            studentEnrollmentCodeAddViewModel._failure = false;
                            studentEnrollmentCodeAddViewModel._message = "Enrollment Code Deleted Successfully";
                        }
                    }
                }
            }
            catch (Exception es)
            {
                studentEnrollmentCodeAddViewModel._failure = true;
                studentEnrollmentCodeAddViewModel._message = es.Message;
            }
            return(studentEnrollmentCodeAddViewModel);
        }
示例#9
0
        /// <summary>
        /// View By Id StudentEnrollmentCode
        /// </summary>
        /// <param name="studentEnrollmentCodeAddViewModel"></param>
        /// <returns></returns>

        public StudentEnrollmentCodeAddViewModel ViewStudentEnrollmentCode(StudentEnrollmentCodeAddViewModel studentEnrollmentCodeAddViewModel)
        {
            StudentEnrollmentCodeAddViewModel studentEnrollmentCodeView = new StudentEnrollmentCodeAddViewModel();

            try
            {
                var studentEnrollmentCodeData = this.context?.StudentEnrollmentCode.FirstOrDefault(x => x.TenantId == studentEnrollmentCodeAddViewModel.studentEnrollmentCode.TenantId && x.SchoolId == studentEnrollmentCodeAddViewModel.studentEnrollmentCode.SchoolId && x.EnrollmentCode == studentEnrollmentCodeAddViewModel.studentEnrollmentCode.EnrollmentCode);
                if (studentEnrollmentCodeData != null)
                {
                    studentEnrollmentCodeView.studentEnrollmentCode = studentEnrollmentCodeData;
                }
                else
                {
                    studentEnrollmentCodeView._failure = true;
                    studentEnrollmentCodeView._message = NORECORDFOUND;
                }
            }
            catch (Exception es)
            {
                studentEnrollmentCodeView._failure = true;
                studentEnrollmentCodeView._message = es.Message;
            }
            return(studentEnrollmentCodeView);
        }