コード例 #1
0
        public JsonResult SaveMainClaim(List <ClaimDetailsViewModel> pmodel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var pcref = GetClaimRef();

                    var pclaimModel = new Pclaim();
                    var userCode    = "";
                    var sum         = new decimal();
                    foreach (var claim in pmodel)
                    {
                        sum     += Convert.ToDecimal(claim.TotalAmount);
                        userCode = claim.UserCode;

                        pclaimModel.Pcref    = pcref;
                        pclaimModel.PayeeRef = claim.UserCode;

                        pclaimModel.Term      = claim.Semester;
                        pclaimModel.Amount    = sum;
                        pclaimModel.Personnel = claim.UserCode;
                        pclaimModel.Rdate     = DateTime.Now;
                        pclaimModel.Notes     = claim.Notes;
                        pclaimModel.Status    = "Pending";
                    }
                    var emp = ReturnUserNames(userCode);
                    pclaimModel.Names = emp.Names;

                    _context.Pclaim.Add(pclaimModel);
                    _context.SaveChanges();
                    var saveStatus = Json(new { });
                    foreach (var claim in pmodel)
                    {
                        saveStatus = SaveIndiviualMainClaims(claim, pcref);
                    }

                    return(Json(new ReturnData <bool>
                    {
                        Success = true,
                        Message = "Claim has been raised successfully "
                    }));
                }

                return(Json(new ReturnData <bool>
                {
                    Success = false,
                    Message = "A server error occured,please contact the administrator : "
                }));
            }
            catch (Exception ex)
            {
                return(Json(new ReturnData <bool>
                {
                    Success = false,
                    Error = new Error(ex),
                    Message = "A server error occured,please contact the administrator : " + ex.Message
                }));
            }
        }
コード例 #2
0
        public JsonResult UpadateStudentProfile(StudentprofileViewModel profileViewModel, string classStatus, ProfileEditor editOperation)
        {
            try
            {
                var register = _context.Register.FirstOrDefault(r => r.AdmnNo.ToUpper().Equals(profileViewModel.AdmnNo.ToUpper()));
                if (editOperation == ProfileEditor.EditContacts)
                {
                    register.Telno       = profileViewModel?.Telno;
                    register.Homeaddress = profileViewModel?.Homeaddress;
                    register.Email       = profileViewModel?.Email;
                }

                if (editOperation == ProfileEditor.EditOthers)
                {
                    register.Language = profileViewModel?.Language;
                    register.Special  = profileViewModel?.Medical;
                    register.Activity = profileViewModel?.Activity;
                }

                if (editOperation == ProfileEditor.EditEmergency)
                {
                    register.Emname    = profileViewModel?.EmergencyName;
                    register.Emrel     = profileViewModel?.EmergencyRelationShip;
                    register.Emtel     = profileViewModel?.EmergencyTelNo;
                    register.Ememail   = profileViewModel?.EmergencyEmail;
                    register.Emaddress = profileViewModel?.EmergencyAddress;
                    register.Emremarks = profileViewModel?.EmergencyRemarks;
                }

                if (editOperation == ProfileEditor.EditDependancies)
                {
                    var dependant = _context.StudDependant.FirstOrDefault(s => s.AdmnNo.ToUpper().Equals(profileViewModel.AdmnNo.ToUpper()));
                    dependant.Names        = profileViewModel?.DependantName;
                    dependant.Relationship = profileViewModel?.DependantRelationShip;
                    dependant.Gender       = profileViewModel?.DependantGender;
                    dependant.Tel          = profileViewModel?.DependantTelNo;
                    dependant.Occupation   = profileViewModel?.DependantOccupation;
                    dependant.Notes        = profileViewModel?.DependantNotes;
                }


                _context.SaveChanges();
                return(Json(new ReturnData <string>
                {
                    Success = true,
                    Message = "Profile Updated Successifully"
                }));
            }
            catch (Exception ex)
            {
                return(Json(new ReturnData <string>
                {
                    Success = false,
                    Message = "An error occurred,please retry : " + ex.Message
                }));
            }
        }
コード例 #3
0
ファイル: RetakeController.cs プロジェクト: Omwitsa/portal
        public JsonResult SaveRetake(RetakeModel retake, string classStatus)
        {
            try
            {
                var retakeReg = _context.RetakeReg.FirstOrDefault(r => r.AdmnNo.ToUpper().Equals(retake.Username.ToUpper()) &&
                                                                  r.Term.ToUpper().Equals(retake.Term.ToUpper()));
                if (retakeReg == null)
                {
                    _context.RetakeReg.Add(new RetakeReg
                    {
                        AdmnNo    = retake.Username,
                        Class     = _studentServices.GetClass(retake.Username, classStatus)?.Data?.Id ?? "",
                        Term      = retake.Term,
                        Rdate     = DateTime.UtcNow,
                        Personnel = retake.Username
                    });
                    _context.SaveChanges();

                    retakeReg = _context.RetakeReg.FirstOrDefault(r => r.AdmnNo.ToUpper().Equals(retake.Username.ToUpper()) &&
                                                                  r.Term.ToUpper().Equals(retake.Term.ToUpper()));
                }


                foreach (var unit in retake.Units)
                {
                    _context.RetakeRegDetail.Add(new RetakeRegDetail {
                        Ref      = retakeReg.Id.ToString(),
                        UnitCode = unit,
                        Notes    = retake?.Notes ?? ""
                    });
                }

                _context.SaveChanges();
                return(Json(new ReturnData <string>
                {
                    Success = true,
                    Message = "Retake applied successfully"
                }));
            }
            catch (Exception ex)
            {
                return(Json(new ReturnData <string>
                {
                    Success = false,
                    Message = "Sorry, An error occurred"
                }));
            }
        }
コード例 #4
0
ファイル: AcademicController.cs プロジェクト: Omwitsa/portal
        public JsonResult RegisterUnits(UnitRegistrationViewModel regunits)
        {
            try
            {
                var progUnitReg = _context.ProgUnitReg.FirstOrDefault(p => p.AdmnNo == regunits.UserCode);

                foreach (var unit in regunits.unitCodes)
                {
                    var registeredUnits = new ProgUnitRegDetail
                    {
                        UnitCode = unit.ProgUnitCode,
                        Ref      = "" + progUnitReg?.Id,
                        Status   = "Pending"
                    };

                    _context.ProgUnitRegDetail.Add(registeredUnits);
                }

                _context.SaveChanges();
                return(Json(new ReturnData <string>
                {
                    Success = true,
                    Message = "Items added successfully"
                }));
            }
            catch (Exception)
            {
                return(Json(new ReturnData <string>
                {
                    Success = false,
                    Message = "Sorry something went wrong while registering units, please try again"
                }));
            }
        }
コード例 #5
0
        public ReturnData <string> SaveToWorkFlowCenter(ProcOnlineReq procOnlineReq, HrpEmployee userDetails, string docId, string notes = null)
        {
            var wkDocCenter = new WfdocCentre
            {
                Type        = procOnlineReq.DocType.ToUpper(),
                DocNo       = procOnlineReq.ReqRef,
                Description = string.IsNullOrEmpty(notes) ? "N/A" : notes,
                UserRef     = userDetails.EmpNo,
                Names       = userDetails.Names,
                Department  = userDetails.Department,
                Rdate       = DateTime.UtcNow,
                Rtime       = DateTime.UtcNow.ToLocalTime(),
                Personnel   = userDetails.EmpNo,
                FinalStatus = "Pending"
            };

            db.WfdocCentre.Add(wkDocCenter);
            db.SaveChanges();

            var documentCenterId = db.WfdocCentre.FirstOrDefault(d => d.DocNo == procOnlineReq.ReqRef)?.Id;

            var WFRoutingDetails = db.WfroutingDetails.Where(d => d.Ref == docId).ToList();

            var departmentHeadTitle = "HEAD OF DEPARTMENT";
            var supervisorTitle     = "SUPERVISOR";
            var deanTitle           = "Dean";

            foreach (var detail in WFRoutingDetails)
            {
                var approver       = db.Wfapprovers.FirstOrDefault(a => a.Title == detail.Approver);
                var approverId     = approver?.Id.ToString();
                var approversCodes = db.WfapproversDetails.Join(db.Users,
                                                                approverDetail => approverDetail.UserCode,
                                                                users => users.UserCode,
                                                                (approverDetail, users) => new
                {
                    approverDetail.Ref,
                    approverDetail.UserCode,
                    users.Department
                }).Where(u => u.Ref == approverId).Select(u => u.UserCode).Distinct().ToList();

                if (detail.Approver.ToLower().Contains(departmentHeadTitle.ToLower()))
                {
                    approversCodes = db.WfapproversDetails.Join(db.Users,
                                                                approverDetail => approverDetail.UserCode,
                                                                users => users.UserCode,
                                                                (approverDetail, users) => new
                    {
                        approverDetail.Ref,
                        approverDetail.UserCode,
                        users.Department
                    }).Where(u => u.Department == userDetails.Department && u.Ref == approverId).Select(u => u.UserCode).Distinct().ToList();
                }

                if (detail.Approver.ToLower().Contains(supervisorTitle.ToLower()))
                {
                    var employeeSupervisor = db.HrpEmployee.FirstOrDefault(e => e.EmpNo == userDetails.EmpNo)?.Supervisor;

                    approversCodes = db.Users.Where(u => u.EmpNo == employeeSupervisor).Select(u => u.UserCode).Distinct().ToList();
                }

                if (detail.Approver.ToLower().Contains(deanTitle.ToLower()))
                {
                    approversCodes = db.Schools.Join(db.Users,
                                                     schools => schools.DeanUserName,
                                                     users => users.UserCode,
                                                     (schools, users) => new
                    {
                        users.UserCode
                    }).Select(u => u.UserCode).Distinct().ToList();
                }

                foreach (var approverCode in approversCodes)
                {
                    var wkDocCenterDetails = new WfdocCentreDetails
                    {
                        Ref            = Convert.ToString(documentCenterId),
                        Approver       = detail.Approver,
                        Level          = detail.Level,
                        UserCode       = approverCode,
                        Action         = "Approval",
                        Reason         = null,
                        Rdate          = DateTime.UtcNow,
                        ActionSelected = null,
                        Station        = null
                    };

                    db.WfdocCentreDetails.Add(wkDocCenterDetails);
                }
            }

            db.SaveChanges();

            return(new ReturnData <string>
            {
                Success = true,
                Data = ""
            });
        }
コード例 #6
0
ファイル: ImprestController.cs プロジェクト: Omwitsa/portal
        public JsonResult SaveEmployeeImprest(ImprestReq imprestReq)
        {
            try
            {
                imprestReq.Rdate    = DateTime.Today;
                imprestReq.Usercode = imprestReq.EmpNo;
                var user = _context.HrpEmployee.FirstOrDefault(u => u.EmpNo == imprestReq.EmpNo);
                if (_studentServices.CheckIfGenesis().Data)
                {
                    var memo = _context.ImprestMemo.Any(m => m.Ref.ToUpper().Equals(imprestReq.MemoRef.ToUpper()) &&
                                                        m.Status.ToUpper().Equals("APPROVED"));
                    if (!memo)
                    {
                        return(Json(new ReturnData <string>
                        {
                            Success = false,
                            Message = "Sorry, Only approved memos can be used to request for an imprest. Kindly contact admin"
                        }));
                    }

                    var memoDetails = _context.ImprestMemoDetail.Any(d => d.EmpNo.ToUpper().Equals(imprestReq.EmpNo.ToUpper()) &&
                                                                     d.Ref.ToUpper().Equals(imprestReq.MemoRef.ToUpper()));

                    if (!memoDetails)
                    {
                        return(Json(new ReturnData <string>
                        {
                            Success = false,
                            Message = $"{user.Names} is not one of the participants on the Memo reference number entered."
                        }));
                    }
                }

                var message = "";
                if (imprestReq.Amount < 0)
                {
                    message = "Amount must be greater than 0";
                }

                if (Convert.ToDateTime(imprestReq.Edate).Date < DateTime.Now.Date)
                {
                    message = "Expected date should be greater than today";
                }

                var imprestNumber = getImprestNumber();

                var procOnlineReq = new ProcOnlineReq
                {
                    ReqRef   = imprestNumber,
                    DocType  = "IMPREST WARRANT",
                    Rdate    = DateTime.Today,
                    Rtime    = DateTime.UtcNow.AddHours(3),
                    Usercode = user.EmpNo,
                    Status   = "Pending",
                };

                //var wfRouting = _staffServices.GetWfRouting(procOnlineReq.DocType);
                //if (!wfRouting.Success)
                //	return Json(wfRouting);

                //if (string.IsNullOrEmpty(wfRouting.Data.Id.ToString()))
                //	return Json(wfRouting);

                //var workFlowStatus = utils.SaveToWorkFlowCenter(procOnlineReq, user, wfRouting.Data.Id.ToString());
                //if (!workFlowStatus.Success)
                //	return Json(workFlowStatus);

                _context.ImprestReq.Add(imprestReq);
                _context.SaveChanges();
                message = "Your imprest has been successfully saved";

                return(Json(new ReturnData <string>
                {
                    Success = true,
                    Message = message
                }));
            }
            catch (Exception ex)
            {
                return(Json(new ReturnData <bool>
                {
                    Success = false,
                    Message = "Oops,seems like an error occurred while processing your request",
                    Error = new Error(ex)
                }));
            }
        }
コード例 #7
0
        public JsonResult SaveStudentsUnits(CurriculumUnitsModel curriculumUnitsModel, string classStatus)
        {
            var studClass = _studentServices.GetClass(curriculumUnitsModel.UserCode, classStatus);

            if (!studClass.Success)
            {
                return(Json(studClass));
            }

            var programme = _studentServices.GetProgramme(curriculumUnitsModel.UserCode, classStatus);

            if (!programme.Success)
            {
                return(Json(programme));
            }

            var maxRegUnits = studClass.Data?.MaxUnits == 0 ? programme.Data?.MaxUnits : studClass.Data?.MaxUnits;

            if (curriculumUnitsModel.CurriculumUnits.Count > maxRegUnits)
            {
                return(Json(new ReturnData <string>
                {
                    Success = false,
                    Message = $"Sorry, you can only register a maximum of {maxRegUnits} units for the current semester"
                }));
            }

            try
            {
                if (_context.SysSetup.Any(s => Convert.ToDateTime(s.UnitRegDeadLine) < DateTime.Now.Date))
                {
                    return(Json(new ReturnData <string>
                    {
                        Success = false,
                        Message = "Oops,seems unit registration deadline has passed"
                    }));
                }

                var hasReported = studentCredentials.ValidateSessionReporting(curriculumUnitsModel.UserCode, classStatus);
                if (!hasReported.Success)
                {
                    return(Json(hasReported));
                }

                if (hasReported.Data != null)
                {
                    if (hasReported.Data.Status.Equals("Pending"))
                    {
                        return(Json(new ReturnData <string>
                        {
                            Success = false,
                            Message = "Sorry, your reporting status is still pending. Kindly contact admin"
                        }));
                    }
                }

                var feePolicyComplied = studentCredentials.ReturnFeesPolicyCompliance(curriculumUnitsModel.UserCode, classStatus, "UNIT");
                if (!feePolicyComplied.Success)
                {
                    return(Json(new ReturnData <string>
                    {
                        Success = false,
                        Message = $"Sorry! Fees payment is required as per the policy before registering for the units. The policy is {feePolicyComplied.Data}% "
                    }));
                }

                var termResponse = _studentServices.GetCurrentTerm(curriculumUnitsModel.UserCode, classStatus);
                if (!termResponse.Success)
                {
                    return(Json(termResponse));
                }

                curriculumUnitsModel.Semester = termResponse.Data?.Names;

                var studEnrolment = _studentServices.GetEnrollment(curriculumUnitsModel.UserCode, classStatus);
                if (!studEnrolment.Success)
                {
                    return(Json(studEnrolment));
                }

                var studentClass             = studEnrolment.Data?.Class;
                var studentRegisteredSession = _context.ProgUnitReg
                                               .FirstOrDefault(s => s.Class == studentClass && s.Term == curriculumUnitsModel.Semester &&
                                                               s.AdmnNo == curriculumUnitsModel.UserCode);

                if (studentRegisteredSession == null)
                {
                    var progUnitReg = new ProgUnitReg
                    {
                        Class     = studentClass,
                        AdmnNo    = curriculumUnitsModel.UserCode,
                        Term      = curriculumUnitsModel.Semester,
                        Rdate     = DateTime.UtcNow,
                        Personnel = curriculumUnitsModel.UserCode
                    };

                    _context.ProgUnitReg.AddRange(progUnitReg);
                    _context.SaveChanges();

                    if (progUnitReg.Id > 0)
                    {
                        curriculumUnitsModel.CurriculumUnits.ForEach(u => {
                            var subjectSelected = new ProgUnitRegDetail
                            {
                                Ref      = progUnitReg.Id.ToString(),
                                UnitCode = u,
                                Status   = "Pending",
                                Audit    = false
                            };
                            _context.ProgUnitRegDetail.Add(subjectSelected);
                        });

                        _context.SaveChanges();
                    }

                    return(Json(new ReturnData <string>
                    {
                        Success = true,
                        Message = "Unit Registration successful, Pending approval from the Chairman of Department (CoD)"
                    }));
                }

                var progUnitRegDetail = _context.ProgUnitRegDetail.Where(u => u.Ref == studentRegisteredSession.Id.ToString());
                var approvedUnits     = progUnitRegDetail.Where(u => u.Status.ToLower().Equals("approved")).Select(u => u.UnitCode.ToUpper()).ToList();
                if ((curriculumUnitsModel.CurriculumUnits.Count + approvedUnits.Count) > maxRegUnits)
                {
                    return(Json(new ReturnData <string>
                    {
                        Success = false,
                        Message = $"Sorry, you can only register a maximum of {maxRegUnits} units for the current semester"
                    }));
                }

                var pendingUnits = progUnitRegDetail.Where(u => u.Status.ToLower().Equals("Pending"));
                _context.ProgUnitRegDetail.RemoveRange(pendingUnits);

                curriculumUnitsModel.CurriculumUnits.ForEach(u => {
                    if (!approvedUnits.Contains(u.ToUpper()))
                    {
                        var subjectSelected = new ProgUnitRegDetail
                        {
                            Ref      = studentRegisteredSession.Id.ToString(),
                            UnitCode = u,
                            Status   = "Pending",
                            Audit    = false
                        };
                        _context.ProgUnitRegDetail.Add(subjectSelected);
                    }
                });

                _context.SaveChanges();

                return(Json(new ReturnData <string>
                {
                    Success = true,
                    Message = "Unit Registration successful, Pending approval from the Chairman of Department (CoD)"
                }));
            }
            catch (Exception ex)
            {
                return(Json(new ReturnData <string>
                {
                    Success = false,
                    Message = "Oops, seems an error has occured on our side.Please contact admin " +
                              ErrorMessangesHandler.ExceptionMessage(ex)
                }));
            }
        }
コード例 #8
0
ファイル: LeaveController.cs プロジェクト: Omwitsa/portal
        public JsonResult ApplyLeave(HrpLeaveApp leave, bool leaveRelieverMandatory)
        {
            try
            {
                leave.LeavePeriod = _context.HrpLeavePeriod.OrderByDescending(p => p.EndDate).FirstOrDefault(p => p.StartDate.Year == DateTime.UtcNow.Year)?.Names ?? DateTime.UtcNow.Year.ToString();
                leave.Reliever    = leave.Reliever ?? "";
                var reliverDetails = leave.Reliever.Split("-(");
                if (reliverDetails.Count() > 1)
                {
                    leave.Reliever = reliverDetails[1] ?? "";
                }
                leave.Reliever = leave.Reliever.Replace(")", "");
                if (leave.LeaveType.ToLower().Equals("maternity leave"))
                {
                    if (!CanApplyMaternityLeave(leave.EmpNo, leave.LeaveType))
                    {
                        return(Json(new ReturnData <HrpLeaveApp>
                        {
                            Success = false,
                            Message = "Application failed. Only Female can apply for this leave",
                            Data = leave
                        }));
                    }
                }

                var leaveExists = _context.HrpLeaveApp.Any(l => l.Status.Equals("Pending") &&
                                                           l.LeaveType.Equals(leave.LeaveType) && l.EmpNo.Equals(leave.EmpNo));
                if (leaveExists)
                {
                    return(Json(new ReturnData <HrpLeaveApp>
                    {
                        Success = false,
                        Message = $"You have a Pending {leave.LeaveType} Application",
                        Data = leave
                    }));
                }

                leave.Ref = GenerateAppNo();
                //var leaveDaysDetails = _staffServices.GetEmpLeaveDays(leave.EmpNo);
                //if (!leaveDaysDetails.Success)
                //	return Json(leaveDaysDetails);

                //var days = leaveDaysDetails.Data.Where(l => l.LeaveType.CaseInsensitiveContains(leave.LeaveType)).Sum(x => x.LeaveDays) ?? 0;
                var days          = _staffServices.GetUserLeavesEntitled(leave.EmpNo, leave.LeaveType);
                var procOnlineReq = new ProcOnlineReq
                {
                    ReqRef   = leave.Ref,
                    DocType  = "LEAVE APPLICATION",
                    Rdate    = DateTime.UtcNow.Date,
                    Rtime    = DateTime.UtcNow.AddHours(3),
                    Usercode = leave.EmpNo,
                    Status   = "Pending"
                };

                var docId = _context.Wfrouting.FirstOrDefault(r => r.Document.ToUpper() == procOnlineReq.DocType.ToUpper())?.Id.ToString();
                if (string.IsNullOrEmpty(docId))
                {
                    return(Json(new ReturnData <string>
                    {
                        Success = false,
                        Message = "Sorry, " + procOnlineReq.DocType.ToUpper() + " Not supported at the moment. Please contact the admin"
                    }));
                }

                if (days < 1)
                {
                    return(Json(new ReturnData <HrpLeaveApp>
                    {
                        Success = false,
                        Message = string.Format("Application failed. Your have {0} days for this leave", days),
                        Data = leave
                    }));
                }

                if (!leaveRelieverMandatory)
                {
                    var user           = _context.HrpEmployee.FirstOrDefault(u => u.EmpNo == leave.EmpNo);
                    var description    = $"Type of Leave: {leave.LeaveType}; Number of days requested: {leave.LeaveDays}; From: {String.Format("{0:d}", leave.Sdate)} To: {String.Format("{0:d}", leave.Edate)}";
                    var workFlowStatus = utils.SaveToWorkFlowCenter(procOnlineReq, user, docId, description);
                    if (!workFlowStatus.Success)
                    {
                        return(Json(workFlowStatus));
                    }
                }

                _context.HrpLeaveApp.Add(leave);
                _context.SaveChanges();
                return(Json(new ReturnData <HrpLeaveApp>
                {
                    Success = true,
                    Message = "Your leave application was submited succesfully",
                    Data = leave
                }));
            }
            catch (Exception e)
            {
                return(Json(new ReturnData <string>
                {
                    Success = false,
                    Message = "There was a problem while trying to apply leave.",
                    Error = new Error(e)
                }));
            }
        }
コード例 #9
0
        public JsonResult AddOnlineReporting(ReportOnlineViewModel reportOnlineModel, string classStatus)
        {
            var sysSetup = _context.SysSetup.FirstOrDefault();

            if (sysSetup.ReportingDeadline.Date < DateTime.UtcNow.Date)
            {
                return(Json(new ReturnData <OnlineReporting>
                {
                    Success = false,
                    Message = "Sorry, Your reporting deadline has expired, Please contact School Admin. ",
                }));
            }

            var plannerDetails = _studentServices.GetSessionPlannerCurrentDetails(reportOnlineModel.UserCode, classStatus);

            if (!plannerDetails.Success)
            {
                return(Json(new ReturnData <OnlineReporting>
                {
                    Success = plannerDetails.Success,
                    Message = plannerDetails.Message,
                }));
            }

            var currentTerm = _studentServices.GetCurrentTerm(reportOnlineModel.UserCode, classStatus);

            if (!currentTerm.Success)
            {
                return(Json(currentTerm));
            }

            var erpReporting = _studentServices.CheckErpReporting(reportOnlineModel.UserCode, classStatus);

            if (erpReporting.Success)
            {
                return(Json(new ReturnData <bool> {
                    Success = false,
                    Message = erpReporting.Message
                }));
            }

            var onlineReporting = _studentServices.CheckOnlineReporting(reportOnlineModel.UserCode, classStatus);

            if (onlineReporting.Success)
            {
                return(Json(new ReturnData <bool>
                {
                    Success = false,
                    Message = onlineReporting.Message
                }));
            }

            var hasReported = studentCredentials.ValidateSessionReporting(reportOnlineModel.UserCode, classStatus);

            if (hasReported.Success)
            {
                return(Json(hasReported));
            }

            _context.OnlineReporting.Add(
                new OnlineReporting
            {
                Term      = currentTerm.Data.Names,
                AdmnNo    = reportOnlineModel.UserCode,
                Personnel = reportOnlineModel.UserCode,
                Rdate     = DateTime.Today,
                Status    = "Pending"
            }
                );

            _context.SaveChanges();

            return(Json(new ReturnData <bool>
            {
                Success = true,
                Message = "You have successfully reported to current semester (" + currentTerm + ")"
            }));
        }
コード例 #10
0
ファイル: UnitOfWork.cs プロジェクト: Omwitsa/portal
 public int Save()
 {
     return(_context.SaveChanges());
 }
コード例 #11
0
        public JsonResult CreateAnSor(CreateSorModel sor)
        {
            try
            {
                var sorNo = GenerateRefNo();
                var user  = _context.HrpEmployee.FirstOrDefault(u => u.EmpNo == sor.Details.Usercode);

                var procOnlineReq = new ProcOnlineReq
                {
                    ReqRef   = sorNo,
                    DocType  = "SPECIFICATION OF REQUIREMENT",
                    Rdate    = DateTime.UtcNow.Date,
                    Rtime    = DateTime.UtcNow.AddHours(3),
                    Usercode = sor.Details.Usercode,
                    Reaction = "",
                    Status   = "Pending",
                    Notes    = sor.Details.Notes
                };

                var wfRouting = _staffServices.GetWfRouting(procOnlineReq.DocType);
                if (!wfRouting.Success)
                {
                    return(Json(wfRouting));
                }

                if (string.IsNullOrEmpty(wfRouting.Data.Id.ToString()))
                {
                    return(Json(wfRouting));
                }

                var workFlowStatus = utils.SaveToWorkFlowCenter(procOnlineReq, user, wfRouting.Data.Id.ToString());
                if (!workFlowStatus.Success)
                {
                    return(Json(workFlowStatus));
                }

                _context.ProcOnlineReq.Add(procOnlineReq);

                foreach (var soritem in sor.Items)
                {
                    _context.ProcOnlineReqDetail.Add(new ProcOnlineReqDetail {
                        Amount      = soritem.Totalamount,
                        Cost        = soritem.Unitamount,
                        Qty         = soritem.Quantity,
                        ReqRef      = procOnlineReq.ReqRef,
                        UoM         = soritem.Unitmeasure,
                        Description = soritem.Description
                    });
                }

                _context.SaveChanges();

                return(Json(new ReturnData <CreateSorModel>
                {
                    Success = true,
                    Message = "SOR submited successfully"
                }));
            }
            catch (Exception ex)
            {
                return(Json(new ReturnData <CreateSorModel>
                {
                    Success = false,
                    Message = "Sorry. Something went wrong.Please try again",
                    Error = new Error(ex)
                }));
            }
        }
コード例 #12
0
        public JsonResult Apply(StudClearance clearance, Role role)
        {
            try
            {
                if (role == Role.Student)
                {
                    var cleared = _context.StudClearances.FirstOrDefault(c => c.AdmnNo.ToUpper().Equals(clearance.AdmnNo.ToUpper()));
                    if (cleared != null)
                    {
                        var message = cleared.Status.ToLower().Equals("approved") ? "You have already cleared" : $"Your clearance is {cleared.Status.ToLower()}";
                        return(Json(new ReturnData <string>
                        {
                            Success = false,
                            Message = message
                        }));
                    }
                }
                if (role == Role.Staff)
                {
                    var cleared = _context.HrpStaffClearance.FirstOrDefault(c => c.EmpNo.ToUpper().Equals(clearance.AdmnNo.ToUpper()));
                    if (cleared != null)
                    {
                        var message = cleared.Status.ToLower().Equals("approved") ? "You have already cleared" : $"Your clearance is {cleared.Status.ToLower()}";
                        return(Json(new ReturnData <string>
                        {
                            Success = false,
                            Message = message
                        }));
                    }
                }

                var docType       = role == Role.Student ? "STUDENT CLEARANCE" : "STAFF CLEARANCE";
                var procOnlineReq = new ProcOnlineReq
                {
                    ReqRef   = clearance.AdmnNo,
                    DocType  = docType.ToUpper(),
                    Rdate    = DateTime.Today,
                    Rtime    = DateTime.UtcNow,
                    Usercode = clearance.AdmnNo,
                    Status   = "Pending"
                };

                var docId = _context.Wfrouting
                            .FirstOrDefault(r => r.Document.ToUpper() == procOnlineReq.DocType.ToUpper())
                            ?.Id.ToString();

                if (string.IsNullOrEmpty(docId))
                {
                    return(Json(new ReturnData <string>
                    {
                        Success = false,
                        Message = "Sorry, " + procOnlineReq.DocType.ToUpper() + " " +
                                  "Not supported at the moment. Please contact the admin"
                    }));
                }

                var user = new HrpEmployee();
                if (role == Role.Staff)
                {
                    user = _context.HrpEmployee.FirstOrDefault(u => u.EmpNo.ToUpper().Equals(clearance.AdmnNo.ToUpper()));
                }
                else
                {
                    user = _context.Register.Join(_context.Programme, r => r.Programme, p => p.Names,
                                                  (r, p) => new HrpEmployee
                    {
                        EmpNo      = r.AdmnNo,
                        Names      = r.Names,
                        Department = p.Department
                    }).FirstOrDefault(r => r.EmpNo.Equals(clearance.AdmnNo));
                }

                var workFlowStatus = _utils.SaveToWorkFlowCenter(procOnlineReq, user, docId, clearance.Notes);
                if (!workFlowStatus.Success)
                {
                    return(Json(workFlowStatus));
                }

                if (role == Role.Student)
                {
                    _context.StudClearances.Add(clearance);
                }
                if (role == Role.Staff)
                {
                    _context.HrpStaffClearance.Add(new HrpStaffClearance {
                        EmpNo     = clearance.AdmnNo,
                        Status    = clearance.Status,
                        Personnel = clearance.Personnel,
                        Notes     = clearance.Notes
                    });
                }

                _context.SaveChanges();

                var msg = $"Your clearance application {clearance.AdmnNo} submited succesfully.";
                return(Json(new ReturnData <string>
                {
                    Success = true,
                    Message = msg,
                    Data = clearance.AdmnNo
                }));
            }
            catch (Exception e)
            {
                return(Json(new ReturnData <string>
                {
                    Success = false,
                    Message = "There was a problem while trying to apply for clearance.",
                    Error = new Error(e)
                }));
            }
        }
コード例 #13
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"
                }));
            }
        }
コード例 #14
0
        public JsonResult CreateIR(CreateSorModel createIR, string usercode)
        {
            try
            {
                var RefNo = GenerateRefNo("IRQ");
                var user  = _context.HrpEmployee.FirstOrDefault(u => u.EmpNo == usercode);

                var procOnlineReq = new ProcOnlineReq
                {
                    ReqRef   = RefNo,
                    DocType  = "Internal Requisition",
                    Usercode = usercode,
                    Reaction = "",
                    Notes    = createIR.Details.Notes,
                    Rdate    = DateTime.UtcNow.Date,
                    Rtime    = DateTime.UtcNow.AddHours(3),
                    Status   = "Pending"
                };

                var wfRouting = _staffServices.GetWfRouting(procOnlineReq.DocType);
                if (!wfRouting.Success)
                {
                    procOnlineReq.DocType = "STORES REQUISITION";
                    wfRouting             = _staffServices.GetWfRouting(procOnlineReq.DocType);
                    if (!wfRouting.Success)
                    {
                        return(Json(wfRouting));
                    }
                }

                if (string.IsNullOrEmpty(wfRouting.Data.Id.ToString()))
                {
                    return(Json(wfRouting));
                }

                var workFlowStatus = utils.SaveToWorkFlowCenter(procOnlineReq, user, wfRouting.Data.Id.ToString());
                if (!workFlowStatus.Success)
                {
                    return(Json(workFlowStatus));
                }

                _context.ProcOnlineReq.Add(procOnlineReq);

                foreach (var irItem in createIR.Items)
                {
                    _context.ProcOnlineReqDetail.Add(new ProcOnlineReqDetail
                    {
                        Amount      = irItem.Totalamount,
                        Cost        = irItem.Unitamount,
                        Qty         = irItem.Quantity,
                        ReqRef      = procOnlineReq.ReqRef,
                        UoM         = irItem.Unitmeasure,
                        Description = irItem.Description
                    });
                }

                _context.SaveChanges();

                return(Json(new ReturnData <ProcOnlineReq>
                {
                    Success = true,
                    Message = "Internal Requisition submited successfully"
                }));
            }
            catch (Exception e)
            {
                return(Json(new ReturnData <ProcOnlineReq>
                {
                    Success = false,
                    Message = "Sorry. Something went wrong.Please try again"
                }));
            }
        }