Пример #1
0
        public IActionResult RejectRequest(string salaryAdvanceNo)
        {
            PostedSalaryAdvanceViewModel vmObj = new PostedSalaryAdvanceViewModel();

            try
            {
                postedsalaryadvancecard          obj    = new postedsalaryadvancecard();
                postedsalaryadvancecard_Filter[] filter =
                {
                    new postedsalaryadvancecard_Filter
                    {
                        Field    = postedsalaryadvancecard_Fields.No,
                        Criteria = salaryAdvanceNo
                    }
                };

                obj = Postedsalaryadvancecard_PortClientService()
                      .ReadMultipleAsync(filter, "", 1)
                      .GetAwaiter()
                      .GetResult()
                      .ReadMultiple_Result1
                      .FirstOrDefault();

                vmObj = _mapper.Map <PostedSalaryAdvanceViewModel>(obj);
            }
            catch (Exception ex)
            {
                TempData["Notify"] = JsonConvert.SerializeObject(new Notify {
                    title = "Exception Error", text = ex.Message, type = "error"
                });
            }
            return(View(vmObj));
        }
Пример #2
0
        public IActionResult RejectRequest(PostedSalaryAdvanceViewModel vmObj)
        {
            try
            {
                ModelState.Remove("Approved_Amount");
                ModelState.Remove("No_of_Months");
                ModelState.Remove("Fixed_Deduction_in_Salary");
                if (ModelState.IsValid)
                {
                    var    obj       = _mapper.Map <postedsalaryadvancecard>(vmObj);
                    Update updateObj = new Update
                    {
                        postedsalaryadvancecard = obj
                    };

                    var result = Postedsalaryadvancecard_PortClientService()
                                 .UpdateAsync(updateObj)
                                 .GetAwaiter()
                                 .GetResult()
                                 .postedsalaryadvancecard;

                    if (result != null)
                    {
                        var postResult = Hrmgt_PortClientService()
                                         .RejectsalaryadvancewebAsync(result.No)
                                         .GetAwaiter()
                                         .GetResult()
                                         .return_value;

                        if (postResult == 200)
                        {
                            TempData["Notify"] = JsonConvert.SerializeObject(new Notify {
                                title = "Reject Salary Advance", text = "Salary advance rejected successfully.", type = "success"
                            });
                            return(RedirectToAction(nameof(Index)));
                        }
                        else
                        {
                            TempData["Notify"] = JsonConvert.SerializeObject(new Notify {
                                title = "Reject Salary Advance", text = "Reject details saved but rejection failed.", type = "error"
                            });
                        }
                    }
                    else
                    {
                        TempData["Notify"] = JsonConvert.SerializeObject(new Notify {
                            title = "Reject Salary Advance", text = "Posting reject details failed.", type = "error"
                        });
                    }
                }
                else
                {
                    TempData["Notify"] = JsonConvert.SerializeObject(new Notify {
                        title = "Reject Salary Advance", text = "Validation Error. Try Again.", type = "error"
                    });
                }
            }
            catch (Exception ex)
            {
                TempData["Notify"] = JsonConvert.SerializeObject(new Notify {
                    title = "Exception Error", text = ex.Message, type = "error"
                });
            }
            return(RedirectToAction(nameof(RejectRequest), new { salaryAdvanceNo = vmObj.No }));
        }
Пример #3
0
        public IActionResult ApproveRequest(PostedSalaryAdvanceViewModel vmObj)
        {
            try
            {
                ModelState.Remove("Reason_for_Rejection");
                if (ModelState.IsValid)
                {
                    var obj = _mapper.Map <postedsalaryadvancecard>(vmObj);
                    obj.Approved_AmountSpecified           = true;
                    obj.No_of_MonthsSpecified              = true;
                    obj.Fixed_Deduction_in_SalarySpecified = true;
                    obj.Employee_Name = null;

                    Update updateObj = new Update
                    {
                        postedsalaryadvancecard = obj
                    };

                    var result = Postedsalaryadvancecard_PortClientService()
                                 .UpdateAsync(updateObj)
                                 .GetAwaiter()
                                 .GetResult()
                                 .postedsalaryadvancecard;

                    if (result != null)
                    {
                        var postResult = Hrmgt_PortClientService()
                                         .ApprovesalaryadvancewebAsync(result.No)
                                         .GetAwaiter()
                                         .GetResult()
                                         .return_value;

                        if (postResult == 200)
                        {
                            TempData["Notify"] = JsonConvert.SerializeObject(new Notify {
                                title = "Verify Salary Advance", text = "Salary advance approved successfully.", type = "success"
                            });
                            return(RedirectToAction(nameof(Index)));
                        }
                        else
                        {
                            TempData["Notify"] = JsonConvert.SerializeObject(new Notify {
                                title = "Verify Salary Advance", text = "Updating salary advance succeeded but posting approval failed.", type = "error"
                            });
                        }
                    }
                    else
                    {
                        TempData["Notify"] = JsonConvert.SerializeObject(new Notify {
                            title = "Verify Salary Advance", text = "Updating salary advance fields failed.", type = "error"
                        });
                    }
                }
                else
                {
                    TempData["Notify"] = JsonConvert.SerializeObject(new Notify {
                        title = "Verify Salary Advance", text = "Validation Error. Try Again.", type = "error"
                    });
                }
            }
            catch (Exception ex)
            {
                TempData["Notify"] = JsonConvert.SerializeObject(new Notify {
                    title = "Exception Error", text = ex.Message, type = "error"
                });
            }
            return(RedirectToAction(nameof(ApproveRequest), new { salaryAdvanceNo = vmObj.No }));
        }