Beispiel #1
0
        public JsonResult GetEmployeeDetails(string EmpID)
        {
            bool returnresult = false;
            DeptLeaveRequestViewModel objmodel = new DeptLeaveRequestViewModel();

            if (EmpID.Length != 8)
            {
                EmpID = EmpID.ToString().PadLeft(8, '0');
            }
            objmodel.EmployeeID = EmpID;
            try
            {
                objmodel            = Mapper.Map <DeptLeaveRequestViewModel>(_IDeptLeaveRequestViewService.GetEmpDetails(EmpID));
                objmodel.EmployeeID = EmpID;
                if (objmodel.EmployeeName == null)
                {
                    GetdataSAP(objmodel);
                }
                if (String.IsNullOrEmpty(objmodel.ApproverId) || objmodel.ApproverId.Trim() == "_")
                {
                    bool approverresult = GetApproverAsync(objmodel);
                    if (approverresult == true)
                    {
                        string approver = objmodel.ApproverId + "_" + objmodel.ApproverName;
                        objmodel.ApproverId = approver;
                    }
                    else
                    {
                        returnresult = true;
                    }
                }
                HttpContext.Session.SetString(Constant.PersonalArea, objmodel.PA);
                HttpContext.Session.SetString(Constant.PersonalSubArea, objmodel.PSA);
                returnresult = true;
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, ex.Message);
                return(Json(new { data = objmodel, result = false }));
            }
            return(Json(new { data = objmodel, result = returnresult }));
        }
Beispiel #2
0
        public IActionResult CreateLeaveRequest()
        {
            LeaveRequestViewModel obj = new LeaveRequestViewModel();

            try
            {
                string firsttimelogin = HttpContext.Session.GetString("FirstTimeLogin");
                if (firsttimelogin == null)
                {
                    GetApprover(obj);
                    HttpContext.Session.SetString("FirstTimeLogin", "yes");
                }
                else
                {
                    string EmpID        = HttpContext.Session.GetString(Constant.EmployeeID);
                    var    returnresult = Mapper.Map <DeptLeaveRequestViewModel>(_IDeptLeaveRequestViewService.GetEmpDetails(EmpID));
                    obj.ApproverId   = returnresult.ApproverId.Split('_')[0];
                    obj.ApproverName = returnresult.ApproverId.Split('_')[1];
                }
                List <SelectListItem> leaveList = new List <SelectListItem>();
                ViewBag.IsChangeLeave = "No";
                string editleaveid = Convert.ToString(TempData["LeaveData"]);
                if (editleaveid != "")
                {
                    obj = Mapper.Map <List <LeaveRequestViewModel> >(_ILeaveRequestViewService.GetLeaveDetailsForChange(Convert.ToInt32(editleaveid))).FirstOrDefault();
                    ViewBag.IsChangeLeave = "Yes";
                }
                obj.PA       = HttpContext.Session.GetString(Constant.PersonalArea);
                obj.PSA      = HttpContext.Session.GetString(Constant.PersonalSubArea);
                obj.Category = HttpContext.Session.GetString(Constant.Category);
                var LeaveCategoryList = _ILeaveRequestViewService.GetLeaveRequest(obj.PA, obj.PSA, obj.Category);
                obj.Leavelist = LeaveCategoryList;
                if (editleaveid != "")
                {
                    obj.Leavelist.Find(x => x.Text == obj.LeaveCategory).Selected = true;
                }
                if (obj.ApproverId.Length != 8)
                {
                    obj.ApproverId = obj.ApproverId.ToString().PadLeft(8, '0');
                }
                obj.ApproverName = obj.ApproverId + '_' + obj.ApproverName;
                obj.EmployeeName = HttpContext.Session.GetString(Constant.SessionUserName);
                return(View((obj)));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, ex.Message);
                return(View((obj)));
            }
        }