Example #1
0
        public object ShowLeave(GetLeaveParam obj)
        {
            LeaveBusiness ObjTerm = new LeaveBusiness();

            var GetTermVar = ObjTerm.GetLeave(obj);

            return(GetTermVar);
        }
Example #2
0
        public object GetLeave(GetLeaveParam tobj)
        {
            SchoolMainContext db = new ConcreateContext().GetContext(tobj.UserName, tobj.Password);

            if (db == null)
            {
                return(new Results()
                {
                    IsSuccess = false, Message = "Invalid User"
                });
            }

            var Info = db.TBLUSERLOGINs.Where(r => r.UserName == tobj.UserName && r.Password == tobj.Password).FirstOrDefault();

            if (Info == null)
            {
                return(new Results()
                {
                    IsSuccess = false, Message = "Invalid User"
                });
            }
            double SactionDays = 0, AvailableDays = 0;
            var    academicyear = db.View_GETACADEMICYEAR.FirstOrDefault();
            int    EmployeeID   = Convert.ToInt16(Info.EmpCode);
            var    GetInfo      = db.TBLLEAVEMASTERs.Where(r => r.EMPLOYEEID == EmployeeID && r.DISPLAY == 1 && r.ACADEMICYEAR == academicyear.ACADEMICYEAR).ToList();

            if (GetInfo.Count != 0)
            {
                for (int i = 0; i < GetInfo.Count(); i++)
                {
                    SactionDays += Convert.ToDouble(GetInfo[i].SANCTIONEDNOOFDAYS);
                }
                var GetTotalLeave = db.TBLLEAVETYPEMASTERs.Where(r => r.EMPLOYEETYPEID == EmployeeID && r.LEAVETYPEID == tobj.LeaveType && r.DISPLAY == 1 && r.ACADEMICYEAR == academicyear.ACADEMICYEAR).FirstOrDefault();
                AvailableDays = Convert.ToDouble(GetTotalLeave.DAYS - SactionDays);

                return(new LeaveList()
                {
                    IsSuccess = true, ApplicableLeaves = GetTotalLeave.DAYS, RemainingLeaves = AvailableDays
                });
            }
            else
            {
                var GetTotalLeave = db.TBLLEAVETYPEMASTERs.Where(r => r.EMPLOYEETYPEID == EmployeeID && r.LEAVETYPEID == tobj.LeaveType && r.DISPLAY == 1 && r.ACADEMICYEAR == academicyear.ACADEMICYEAR).FirstOrDefault();
                //AvailableDays = Convert.ToDouble(GetTotalLeave.DAYS - SactionDays);
                return(new LeaveList()
                {
                    IsSuccess = true, ApplicableLeaves = GetTotalLeave.DAYS, RemainingLeaves = GetTotalLeave.DAYS
                });
            }
        }