示例#1
0
        //  public bool validateleaves(string leavecode,string employeeid, datetime? fromdate, datetime? todate, out string errormsg)
        public bool validateleaves(string leavecode, string employeeid, decimal nofdays, out string errormsg)
        {
            try
            {
                errormsg = string.Empty;

                using (MobileContext context = new MobileContext())
                {
                    LeaveBalanceMaster leavebalancemaster = context.LeaveBalanceMaster
                                                            .Where(l => l.LeaveCode == leavecode && l.EmpCode == employeeid).FirstOrDefault();


                    if (leavebalancemaster == null)
                    {
                        errormsg = "No leave balace configured from employee :" + employeeid;
                        return(false);
                    }


                    //   if (calculatenoofdays(fromdate, todate) > leavebalancemaster.balance)
                    if (nofdays > Convert.ToDecimal(leavebalancemaster.Balance))
                    {
                        errormsg = "desont have sucfficient days";
                        return(false);
                    }

                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#2
0
        public LeaveBalanceMaster Update(LeaveBalanceMaster lbm)
        {
            try
            {
                using Repository <LeaveBalanceMaster> repo = new Repository <LeaveBalanceMaster>();
                repo.LeaveBalanceMaster.Update(lbm);
                if (repo.SaveChanges() > 0)
                {
                    return(lbm);
                }

                return(null);
            }
            catch { throw; }
        }
示例#3
0
        public LeaveBalanceMaster Register(LeaveBalanceMaster lbm)
        {
            try
            {
                using Repository <LeaveBalanceMaster> repo = new Repository <LeaveBalanceMaster>();
                //lbm.Active = "Y";
                repo.LeaveBalanceMaster.Add(lbm);
                if (repo.SaveChanges() > 0)
                {
                    return(lbm);
                }

                return(null);
            }
            catch { throw; }
        }
        public IActionResult RegisterLeaveBalancesList([FromBody] LeaveBalanceMaster lbm)
        {
            if (lbm == null)
            {
                return(Ok(new APIResponse()
                {
                    status = APIStatus.PASS.ToString(), response = "object can not be null"
                }));
            }

            try
            {
                if (new LeaveBalancesHelper().GetList(lbm.LeaveCode).Count() > 0)
                {
                    return(Ok(new APIResponse()
                    {
                        status = APIStatus.PASS.ToString(), response = $"LeaveCode Code {nameof(lbm.LeaveCode)} is already exists ,Please Use Different Code "
                    }));
                }

                var         result = new LeaveBalancesHelper().Register(lbm);
                APIResponse apiResponse;
                if (result != null)
                {
                    apiResponse = new APIResponse()
                    {
                        status = APIStatus.PASS.ToString(), response = result
                    };
                }
                else
                {
                    apiResponse = new APIResponse()
                    {
                        status = APIStatus.FAIL.ToString(), response = "Registration Failed."
                    };
                }

                return(Ok(apiResponse));
            }
            catch (Exception ex)
            {
                return(Ok(new APIResponse()
                {
                    status = APIStatus.FAIL.ToString(), response = ex.Message
                }));
            }
        }
        public IActionResult UpdateLeaveBalancesList([FromBody] LeaveBalanceMaster lbm)
        {
            if (lbm == null)
            {
                return(Ok(new APIResponse {
                    status = APIStatus.FAIL.ToString(), response = $"{nameof(lbm)} cannot be null"
                }));
            }

            try
            {
                var         rs = new LeaveBalancesHelper().Update(lbm);
                APIResponse apiResponse;
                if (rs != null)
                {
                    apiResponse = new APIResponse()
                    {
                        status = APIStatus.PASS.ToString(), response = rs
                    };
                }
                else
                {
                    apiResponse = new APIResponse()
                    {
                        status = APIStatus.FAIL.ToString(), response = "Updation Failed."
                    };
                }
                return(Ok(apiResponse));
            }
            catch (Exception ex)
            {
                return(Ok(new APIResponse()
                {
                    status = APIStatus.FAIL.ToString(), response = ex.Message
                }));
            }
        }
示例#6
0
        public List <LeaveApplDetails> LeaveApprovalProcess(string employeecode, List <LeaveApplDetails> leaveappldetails)
        {
            try
            {
                List <LeaveApplDetails> prcoessemployess    = new List <LeaveApplDetails>();
                LeaveBalanceMaster      _leavebalancemaster = null;
                using (MobileContext context = new MobileContext())
                {
                    foreach (var lvaply in leaveappldetails)
                    {
                        try
                        {
                            var _employee = context.Employees.Where(x => x.Code == lvaply.EmpCode).FirstOrDefault();
                            if (_employee.RecommendedBy?.Trim() == employeecode.Trim())
                            {
                                // lvaply.Status = STATUS.INPROGRESS.ToString();
                                lvaply.RecommendedId   = employeecode;
                                lvaply.RecommendedName = getemployee(lvaply.RecommendedId)?.Name;
                            }

                            if (_employee.ApprovedBy?.Trim() == employeecode.Trim())
                            {
                                //lvaply.Status = STATUS.APPROVED.ToString();
                                //lvaply.ApprovedDate = DateTime.Now;
                                lvaply.ApprovedId   = employeecode;
                                lvaply.ApprovedName = getemployee(lvaply.ApprovedId)?.Name;
                            }


                            if (lvaply.Status.Equals(STATUS.CANCEL.ToString(), StringComparison.OrdinalIgnoreCase))
                            {
                                updateusedleaves(lvaply.EmpCode, lvaply.LeaveDays, context, true);
                                context.LeaveApplDetails.Update(lvaply);
                                context.SaveChanges();
                                prcoessemployess.Add(lvaply);
                                continue;
                            }

                            // if (_employee != null)
                            // {
                            if (_employee.RecommendedBy?.Trim() == employeecode.Trim())
                            {
                                lvaply.Status = STATUS.INPROGRESS.ToString();
                                //lvaply.RecommendedId = employeecode;
                                //lvaply.RecommendedName = getemployee(lvaply.RecommendedId)?.Name;
                                //context.LeaveApplDetails.Update(lvaply);
                            }

                            if (_employee.ApprovedBy?.Trim() == employeecode.Trim())
                            {
                                lvaply.Status       = STATUS.APPROVED.ToString();
                                lvaply.ApprovedDate = DateTime.Now;
                                //context.LeaveApplDetails.Update(lvaply);
                            }
                            context.LeaveApplDetails.Update(lvaply);
                            context.SaveChanges();
                            prcoessemployess.Add(lvaply);
                            //}
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                }

                return(prcoessemployess);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }