Esempio n. 1
0
        public HttpResponseMessage UpdatePayslip(Payslip payslip)
        {
            HttpResponseMessage response = null;

            try
            {
                if (payslip != null)
                {
                    Payslip pay_slip = PayslipRepo.GetExistingPayslip(payslip.emp_id, payslip.payslip_month, payslip.payslip_year);
                    //pay_slip.emp_id = payslip.emp_id;
                    pay_slip.incometax = payslip.incometax;
                    pay_slip.arrears   = payslip.arrears;
                    PayslipRepo.UpdatePayslip(pay_slip);
                    response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_001", "payslip successfully updated", "payslip successfully updated"));
                }
                else
                {
                    response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_102", "Invalid Input", "please check input json"));
                }
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception.Message);
                Debug.WriteLine(exception.GetBaseException());
                response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_101", "Application Error", exception.Message));
            }
            return(response);
        }
Esempio n. 2
0
        public HttpResponseMessage GeneratePayslip(int employee_id)//e_id employee_id
        {
            HttpResponseMessage response = null;

            try
            {
                if (employee_id != 0)
                {
                    Salary_Structure salary            = SalaryRepo.GetSalaryStructureByEmpId(employee_id);
                    Payslip          payslip           = SalaryCalculation.Calculatepayslip(salary);
                    Payslip          existing_instance = PayslipRepo.GetExistingPayslip(payslip.emp_id, payslip.payslip_month, payslip.payslip_year);
                    if (payslip != null && existing_instance == null)
                    {
                        PayslipRepo.AddPayslip(payslip);
                        response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_001", "Pay slip generated successfully!", "Pay slip generated successfully!"));
                    }
                    else
                    {
                        response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_603", "Failure : Pay slip generation Error or payslip for specified month is already exists", "Pay slip generation Error or payslip for specified month is already exists"));
                    }
                }
                else
                {
                    response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_102", "Invalid Input", "Please check input Json"));
                }
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception.Message);
                Debug.WriteLine(exception.GetBaseException());
                response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_101", "Application Error", exception.Message));
            }
            return(response);
        }