Ejemplo n.º 1
0
        public async Task <IActionResult> RequestAdvance(AdvanceRequestModel model)
        {
            var requestAdvanceProcessing = new AdvanceRequestProcessing(_dbContext);

            var advanceRequest = model.Map();

            advanceRequest.Status = AdvanceRequestStatus.AguardandoAnalise;

            if (!requestAdvanceProcessing.Process(advanceRequest))
            {
                return(new AdvanceRequestErrorJson(requestAdvanceProcessing));
            }

            return(new AdvanceRequestJson(requestAdvanceProcessing.Request));
        }
Ejemplo n.º 2
0
        public List <AdvanceRequestModel> GetAllAdvanceRequestsToEmployee(int empoyeeID)
        {
            List <AdvanceRequestModel> lst = new List <AdvanceRequestModel>();

            try
            {
                List <vAdvanceRequestApplication> lstRequests = _dbContext.vAdvanceRequestApplications.Where(x => x.FK_RequestTo == empoyeeID).OrderByDescending(x => x.RequestDate).ToList();
                foreach (vAdvanceRequestApplication item in lstRequests)
                {
                    AdvanceRequestModel model = new AdvanceRequestModel();
                    model.PK_AdvancRequestID = item.PK_AdvancRequestID;
                    model.RequestDate        = item.RequestDate;
                    model.RequestedAmount    = item.RequestedAmount;
                    model.Remarks            = item.Remarks;
                    model.RemarksApproved    = item.RemarksApproved;
                    model.FK_RequestTo       = item.FK_RequestTo;
                    model.FK_EmployeeID      = item.FK_EmployeeID;
                    model.FK_ApprovedBy      = item.FK_ApprovedBy;
                    model.EmployeeName       = item.EmployeeName;
                    model.ApproverName       = item.ApproverName;
                    model.ApprovedAmount     = item.ApprovedAmount;
                    model.ApprovalStatus     = item.ApprovalStatus;
                    model.ApprovalDate       = item.ApprovalDate;
                    model.AdvanceRequestNo   = item.AdvanceRequestNo;
                    model.Fk_BranchID        = item.Fk_BranchID;
                    model.FK_CompanyID       = item.FK_CompanyID;
                    model.Fk_YearID          = item.Fk_YearID;
                    model.IsDeleted          = item.IsDeleted;
                    model.StatusDescription  = item.StatusDescription;

                    lst.Add(model);
                }
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "ServiceAdvanceRequest::GetAllAdvanceRequestsOfEmployee", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(lst);
        }