コード例 #1
0
        public bool Insert(LoanRequestVM loanrequestVM)
        {
            var push = new LoanRequest(loanrequestVM);

            if (push != null)
            {
                var getUser = applicationcontext.Users.SingleOrDefault(x => x.IsDelete == false && x.Id == loanrequestVM.UserId);
                push.User = getUser;
                applicationcontext.LoanRequests.Add(push);
                var result = applicationcontext.SaveChanges();
                return(result > 0);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
        public bool Update(int id, LoanRequestVM loanrequestVM)
        {
            var get = Get(id);

            if (get != null)
            {
                var getUser = applicationcontext.Users.SingleOrDefault(x => x.IsDelete == false && x.Id == loanrequestVM.UserId);
                get.User = getUser;
                get.Update(loanrequestVM);
                applicationcontext.Entry(get).State = EntityState.Modified;
                var result = applicationcontext.SaveChanges();
                return(result > 0);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
 public bool Update(int id, LoanRequestVM loanrequestVM)
 {
     return(iloanrequestrepository.Update(id, loanrequestVM));
 }
コード例 #4
0
 // categoryVM adalah object
 public bool Insert(LoanRequestVM loanrequestVM)
 {
     return(iloanrequestrepository.Insert(loanrequestVM));
 }
コード例 #5
0
 public void Update(LoanRequestVM loanrequestVM)
 {
     this.Date       = loanrequestVM.Date;
     this.Status     = loanrequestVM.Status;
     this.UpdateDate = DateTimeOffset.Now.LocalDateTime;
 }
コード例 #6
0
 public LoanRequest(LoanRequestVM loanrequestVM)
 {
     this.Date       = loanrequestVM.Date;
     this.Status     = loanrequestVM.Status;
     this.CreateDate = DateTimeOffset.Now.LocalDateTime;
 }
コード例 #7
0
        public async Task <IActionResult> AssignLoan([FromForm] LoanRequestVM loanrequest)
        {
            List <CustomerLoanDocumentDtl> lstLoanDocument = new List <CustomerLoanDocumentDtl>();
            string folderName  = "CustomerDoc";
            var    currentUser = HttpContext.User;
            Int32  userId      = Convert.ToInt32(currentUser.Claims.FirstOrDefault(c => c.Type == "user_id").Value);

            try
            {
                CustomerLoan objCustomerLoan = new CustomerLoan();
                var          loan            = JsonConvert.DeserializeObject <LoadDetailVM>(loanrequest.loandetail);
                if (loan != null)
                {
                    objCustomerLoan           = _mapper.Map <CustomerLoan>(loan);
                    objCustomerLoan.CreatedBy = userId;
                    objCustomerLoan.AgentId   = userId;

                    objCustomerLoan.CreatedDate = DateTime.Now;
                    _context.CustomerLoan.Add(objCustomerLoan);
                    _context.SaveChanges();

                    #region CustomerLoanTxn

                    if (loan.lsttenure != null && loan.lsttenure.Count > 0)
                    {
                        if (objCustomerLoan.CustomerLoanId > 0)
                        {
                            List <CustomerLoanTxn> lstCustomerLoanTxn = new List <CustomerLoanTxn>();
                            lstCustomerLoanTxn = _mapper.Map <List <CustomerLoanTxn> >(loan.lsttenure);
                            foreach (var tenure in lstCustomerLoanTxn)
                            {
                                tenure.CreatedBy      = userId;
                                tenure.CreatedDate    = DateTime.Now;
                                tenure.CustomerLoanId = objCustomerLoan.CustomerLoanId;
                                _context.CustomerLoanTxn.Add(tenure);
                                _context.SaveChanges();
                            }
                        }
                    }

                    #endregion


                    #region AgentBalanceMst

                    AgentBalanceMst objAgentBalanceMst = _context.AgentBalanceMst.FirstOrDefault(x => x.AgentId == userId);
                    if (objAgentBalanceMst != null)
                    {
                        objAgentBalanceMst.Lb                    = objAgentBalanceMst.Lb - loan.LoanAmount;
                        objAgentBalanceMst.UpdatedBy             = userId;
                        objAgentBalanceMst.UpdatedDate           = DateTime.Now;
                        _context.Entry(objAgentBalanceMst).State = EntityState.Modified;
                        _context.SaveChanges();
                    }

                    #endregion

                    #region Upload Customer Loan Doc

                    if (loanrequest.uploadDoc != null)
                    {
                        foreach (var file in loanrequest.uploadDoc)
                        {
                            CustomerLoanDocumentDtl docDtl = new CustomerLoanDocumentDtl();
                            if (file.filedata == null && !string.IsNullOrEmpty(file.Filename))
                            {
                                //return BadRequest("Empty File");
                                docDtl.CustomerLoanId = objCustomerLoan.CustomerLoanId;
                                docDtl.DocumentTypeId = file.DocType;
                                docDtl.FileName       = file.Filename;
                                docDtl.UploadedDate   = DateTime.Now;
                                docDtl.UploadedBy     = userId;
                                lstLoanDocument.Add(docDtl);
                            }
                            else if (file.filedata != null)
                            {
                                //if (file.Length > 2 * 1024 * 1024) return BadRequest("Max file size exceeded.");
                                string webRootPath     = _hostingEnvironment.WebRootPath;
                                string uploadFilesPath = Path.Combine(webRootPath, folderName);
                                if (!Directory.Exists(uploadFilesPath))
                                {
                                    Directory.CreateDirectory(uploadFilesPath);
                                }

                                var fileName = Path.GetFileNameWithoutExtension(file.filedata.FileName) + "-" + Guid.NewGuid().ToString() + Path.GetExtension(file.filedata.FileName);
                                var filePath = Path.Combine(uploadFilesPath, fileName);
                                using (var stream = new FileStream(filePath, FileMode.Create))
                                {
                                    await file.filedata.CopyToAsync(stream);
                                }

                                docDtl.CustomerLoanId = objCustomerLoan.CustomerLoanId;
                                docDtl.DocumentTypeId = file.DocType;
                                docDtl.FileName       = fileName;
                                docDtl.UploadedDate   = DateTime.Now;
                                docDtl.UploadedBy     = userId;
                                lstLoanDocument.Add(docDtl);
                            }
                            else
                            {
                                break;
                            }
                        }
                        _context.CustomerLoanDocumentDtl.AddRange(lstLoanDocument);
                        _context.SaveChanges();
                    }

                    #endregion
                }
            }
            catch (Exception ex)
            {
                return(StatusCode((int)HttpStatusCode.ExpectationFailed));
            }
            return(Ok(new { success = true }));
        }