Ejemplo n.º 1
0
        public IActionResult RegisterPayrollCycle([FromBody] PayrollCycle payCycle)
        {
            if (payCycle == null)
            {
                return(Ok(new APIResponse()
                {
                    status = APIStatus.FAIL.ToString(), response = $"{nameof(payCycle)} cannot be null"
                }));
            }
            else
            {
                if (PayrollCycleHelper.GetPayrollCycle(payCycle.CycleName) != null)
                {
                    return(Ok(new APIResponse()
                    {
                        status = APIStatus.FAIL.ToString(), response = "Code =" + payCycle.CycleName + " is already Exists,Please Use Another Code"
                    }));
                }

                try
                {
                    APIResponse apiResponse = null;
                    var         result      = PayrollCycleHelper.Register(payCycle);
                    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
                    }));
                }
            }
        }
Ejemplo n.º 2
0
        public IActionResult DeletevPF(string code)
        {
            if (code == null)
            {
                return(Ok(new APIResponse()
                {
                    status = APIStatus.PASS.ToString(), response = $"{nameof(code)}can not be null"
                }));
            }

            try
            {
                var         result = PayrollCycleHelper.Delete(code);
                APIResponse apiResponse;
                if (result != null)
                {
                    apiResponse = new APIResponse()
                    {
                        status = APIStatus.PASS.ToString(), response = result
                    };
                }
                else
                {
                    apiResponse = new APIResponse()
                    {
                        status = APIStatus.FAIL.ToString(), response = "Deletion Failed."
                    };
                }
                return(Ok(apiResponse));
            }
            catch (Exception ex)
            {
                return(Ok(new APIResponse {
                    status = APIStatus.FAIL.ToString(), response = ex.Message
                }));
            }
        }
Ejemplo n.º 3
0
        public IActionResult UpdatePayrollCycle([FromBody] PayrollCycle payCycle)
        {
            if (payCycle == null)
            {
                return(Ok(new APIResponse()
                {
                    status = APIStatus.PASS.ToString(), response = $"{nameof(payCycle)} cannot be null"
                }));
            }
            try
            {
                APIResponse apiResponse = null;

                PayrollCycle result = PayrollCycleHelper.Update(payCycle);
                if (result != null)
                {
                    apiResponse = new APIResponse()
                    {
                        status = APIStatus.PASS.ToString(), response = result
                    };
                }
                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
                }));
            }
        }
Ejemplo n.º 4
0
 public IActionResult GetPayrollCycleList()
 {
     try
     {
         var payCycle = PayrollCycleHelper.GetListOfPayrollCycles();
         if (payCycle.Count > 0)
         {
             dynamic expdoObj = new ExpandoObject();
             expdoObj.payCycle = payCycle;
             return(Ok(new APIResponse {
                 status = APIStatus.PASS.ToString(), response = expdoObj
             }));
         }
         return(Ok(new APIResponse {
             status = APIStatus.FAIL.ToString(), response = "No Data Found."
         }));
     }
     catch (Exception ex)
     {
         return(Ok(new APIResponse {
             status = APIStatus.FAIL.ToString(), response = ex.Message
         }));
     }
 }