Пример #1
0
        public bool ApplyLoanDAL(LoanEntities loan)
        {
            try
            {
                DateTime time        = DateTime.Now;
                string   currentTime = time.ToString("yyyyMMddhhmmss");

                if ((int)loan.Type == 0)
                {                                            //eduloan
                    loan.LoanID       = "EDU" + currentTime; //string concatenation loanID sample : EDULOAN20190912101552
                    loan.InterestRate = 10;
                }
                else if ((int)loan.Type == 1)
                {                                             //homeloan
                    loan.LoanID       = "HOME" + currentTime; //string concatenation loanID sample : HOMELOAN20190912101552
                    loan.InterestRate = 10.85;
                }
                else//car loan
                {
                    loan.LoanID       = "CAR" + currentTime; //string concatenation loanID sample : CARLOAN20190912101552
                    loan.InterestRate = 8;
                }

                loan.DateOfApplication = time;
                loan.Status            = (LoanStatus)Enum.Parse(typeof(LoanStatus), "APPLIED");

                Loans.Add(loan);
                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
Пример #2
0
        //-> SaveUploadFiles
        public static async Task <List <sm_doc> > SaveUploadFiles(LoanEntities db, int tableID, int recordID, HttpRequestBase Request)
        {
            var           files     = Request.Files;
            List <sm_doc> documents = new List <sm_doc>();

            if (files != null)
            {
                for (int i = 0; i < files.Count; i++)
                {
                    if (files[i].ContentLength == 0)
                    {
                        continue;
                    }

                    string pathForSavingToDB = "", imageNameForSavingToDB = "";
                    string path = "";
                    string uploadFolderName = "uploads";
                    path = HttpContext.Current.Server.MapPath(@"~\" + uploadFolderName);
                    path = System.Configuration.ConfigurationManager.AppSettings["mediaURL"] + @"\" + uploadFolderName;
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }

                    string currentYear = DateTime.Now.Year.ToString();
                    path += @"\" + currentYear;
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }

                    string currentMonth = DateTime.Now.Month > 9 ? DateTime.Now.Month.ToString() : "0" + DateTime.Now.Month;
                    path += @"\" + currentMonth;

                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }

                    var createImageUniqueName = tableID + "_" + recordID + "_" + DateTime.Now.ToString("yyyy-MM-dd_HHmmssfff") + "_" + i + ".jpg";//in order to avoid redundant image path , use i (variable)
                    files[i].SaveAs(path + @"\" + createImageUniqueName);


                    pathForSavingToDB = uploadFolderName + "/" + currentYear + "/" + currentMonth + "/" + createImageUniqueName;

                    var document = new sm_doc();
                    document.docs_Name        = createImageUniqueName;
                    document.docs_TableID     = tableID;
                    document.docs_CreatedDate = DateTime.Now;
                    document.docs_Value       = recordID.ToString();
                    document.docs_FilePath    = pathForSavingToDB;
                    db.sm_doc.Add(document);
                    await db.SaveChangesAsync();

                    documents.Add(document);
                }
            }
            return(documents);
        }
Пример #3
0
        ////////////////////////////////////////////////////////////////////////////////
        public LoanEntities GetLoanByLoanID_DAL(string loanID)
        {
            foreach (LoanEntities loan in Loans)
            {
                if (loan.LoanID.Equals(loanID) == true)
                {
                    return(loan);
                }
            }

            //// if not found return a null object
            LoanEntities emptyObj = new LoanEntities();

            return(emptyObj);
        }
Пример #4
0
        //-> Get Document
        public static List <DocumentViewDTO> GetDocuments(LoanEntities db, int tableID, int recordID)
        {
            string domain = HttpContext.Current.Request.Url.Authority;
            List <DocumentViewDTO> documentViews = new List <DocumentViewDTO>();
            IQueryable <sm_doc>    documents     = from d in db.sm_doc
                                                   where d.docs_Deleted == null && d.docs_TableID == tableID && d.docs_Value == recordID.ToString()
                                                   orderby d.docs_docID ascending
                                                   select d;

            foreach (var document in documents)
            {
                var docView = MappingHelper.MapDBClassToDTO <sm_doc, DocumentViewDTO>(document);
                docView.fullPath = domain + "/" + docView.path;
                documentViews.Add(docView);
            }

            return(documentViews);
        }
Пример #5
0
        public bool ApplyLoanBL(LoanEntities loan)
        {
            if (Regex.IsMatch(loan.CustomerID, "[0-9]{14}$") == false)
            {
                throw new InvalidStringException("Customer ID must be of 14 digits!");
            }

            if (loan.AmountApplied < 50000 || loan.AmountApplied > 10000000)
            {
                throw new InvalidAmountException("Loan amount must be between Rs.50000 to Rs.10000000 !");
            }

            if (loan.Tenure > 10)
            {
                throw new InvalidRangeException("Tenure can be maximum of 10 years!");
            }

            //LoanType loanType;
            //if(Enum.TryParse(Parse.ToString(loan.Type), out loanType) == true)
            //{
            // for education loan no income bar required

            if ((int)loan.Type == 1 && loan.Income < 50000)     // home loan
            {
                throw new InvalidAmountException("For applying home loan you must have minimum income of Rs.50000/month !");
            }

            if ((int)loan.Type == 2 && loan.Income < 30000)    //car loan
            {
                throw new InvalidAmountException("For applying car loan you must have minimum income of Rs.30000/month !");
            }
            //}
            //else
            //    throw new InvalidEnumException("Not a valid loan type, must be among HOMELOAN, EDULOAN, CARLOAN");

            LoanDAL loanDALobj = new LoanDAL();

            return(loanDALobj.ApplyLoanDAL(loan));
        }
Пример #6
0
 public CheckLoanRequestHandler()
 {
     db = new LoanEntities();
 }
Пример #7
0
 public AccountHandler()
 {
     db = new LoanEntities();
 }