Beispiel #1
0
        public JsonResult ReturnClassStatus()
        {
            var isGenesisDetails = _studentServices.CheckIfGenesis();

            if (!isGenesisDetails.Success)
            {
                var classStatus        = _context.ClassStatus.ToList();
                var institutionInitial = _systemServices.GetSystemSetup()?.Data?.SubTitle ?? "";
                var status             = new
                {
                    classStatus,
                    institutionInitial
                };

                return(Json(new ReturnData <dynamic>
                {
                    Success = classStatus.Count > 0,
                    Data = status
                }));
            }
            return(Json(new ReturnData <dynamic>
            {
                Success = true
            }));
        }
Beispiel #2
0
        public JsonResult ReturnStudentDetails([FromBody] RegisterViewModel reg, string classStatus)
        {
            try
            {
                var studentDetails = studentCredentials.GetStudentDetails(reg.RegNumber, classStatus);
                if (!studentDetails.Success)
                {
                    return(Json(new ReturnData <string>
                    {
                        Success = studentDetails.Success,
                        Message = studentDetails.Message
                    }));
                }

                var studentProgramme = _studentServices.GetProgramme(reg.RegNumber, classStatus);
                if (!studentProgramme.Success)
                {
                    return(Json(new ReturnData <string>
                    {
                        Success = studentProgramme.Success,
                        Message = studentProgramme.Message
                    }));
                }

                var studentClass = _studentServices.GetClass(reg.RegNumber, classStatus);
                if (!studentClass.Success)
                {
                    return(Json(new ReturnData <string>
                    {
                        Success = studentClass.Success,
                        Message = studentClass.Message
                    }));
                }

                var sysSetup = _systemServices.GetSystemSetup();
                if (!sysSetup.Success)
                {
                    return(Json(new ReturnData <string>
                    {
                        Success = sysSetup.Success,
                        Message = sysSetup.Message
                    }));
                }

                var data = new
                {
                    studentDetails.Data.AdmnNo,
                    studentDetails.Data.Names,
                    studentDetails.Data.Gender,
                    studentDetails.Data.Telno,
                    studentDetails.Data.Email,
                    studentDetails.Data.Programme,
                    ProgrammeCode = studentProgramme.Data.Code,
                    studentProgramme.Data.Department,
                    StudentClass        = studentClass.Data.Id,
                    EndOfAcademicRecord = String.Format("{0:dd/MM/yyyy}", studentClass.Data.Ends),
                    StudentCampus       = studentClass.Data.Campus,
                    studentDetails.Data.Sponsor,
                    studentDetails.Data.Homeaddress,
                    studentDetails.Data.Domicile,
                    UniversityName     = sysSetup.Data.OrgName,
                    UniversityInitials = sysSetup.Data.SubTitle
                };

                return(Json(new ReturnData <dynamic>
                {
                    Success = sysSetup.Success,
                    Data = data,
                    Message = sysSetup.Message,
                }));
            }
            catch (Exception ex)
            {
                return(Json(new ReturnData <string>
                {
                    Success = false,
                    Message = "Sorry, An error occurred while accessing a resource. Please contact School admin"
                }));
            }
        }
Beispiel #3
0
        public JsonResult BookHostel(HostelBookingModel hostelBookingModel, string classStatus, string hostelRatio)
        {
            try
            {
                var booking = new HostelBooking
                {
                    AdmnNo    = hostelBookingModel.AdmnNo,
                    Notes     = null,
                    Term      = hostelBookingModel.Term,
                    Personnel = hostelBookingModel.Personnel,
                    Hostel    = hostelBookingModel.Hostel,
                    Rdate     = DateTime.Now.Date
                };
                if (_context.HostelBooking.Any(h => h.AdmnNo.Contains(hostelBookingModel.AdmnNo) && h.Term.Contains(hostelBookingModel.Term)))
                {
                    return(Json(new ReturnData <List <HostelBooking> >
                    {
                        Success = false,
                        Message = "Your have already booked for this semester"
                    }));
                }

                var percentages = hostelRatio.Split(")*(");
                var sponsor     = _context.Register.FirstOrDefault(r => r.AdmnNo.ToUpper().Equals(hostelBookingModel.AdmnNo.ToUpper()))?.Sponsor;
                int percentage  = 0;
                if (percentages.Length > 1)
                {
                    if (sponsor.ToUpper().Equals("NYS"))
                    {
                        int.TryParse(percentages[1], out percentage);
                    }
                    else
                    {
                        int.TryParse(percentages[0], out percentage);
                    }
                }

                double ratio = percentage * 0.01;
                if (CheckIfRoomIsBookable(hostelBookingModel.Hostel, hostelBookingModel.Term, ratio, hostelBookingModel.AdmnNo))
                {
                    return(Json(new ReturnData <List <HostelBooking> >
                    {
                        Success = false,
                        Message = "Sorry, maximum occupancy has been reached"
                    }));
                }

                var inistitutionInitial = _systemServices.GetSystemSetup()?.Data?.SubTitle ?? "";
                if (inistitutionInitial.ToUpper().Equals("UOEM"))
                {
                    var studInvoiced = InvoiceStudent(hostelBookingModel, classStatus);
                    if (!studInvoiced.Success)
                    {
                        return(Json(new ReturnData <List <HostelBooking> >
                        {
                            Success = false,
                            Message = "Sorry, An error occurred while invoicing"
                        }));
                    }
                }

                _context.HostelBooking.Add(booking);
                _context.SaveChanges();
                return(Json(new ReturnData <List <HostelBooking> >
                {
                    Success = true,
                    Message = "Your hostel booking was submited succesfully"
                }));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(Json(new ReturnData <string>
                {
                    Success = false,
                    Message = "There was a problem while trying to submit your booking"
                }));
            }
        }