Exemplo n.º 1
0
        public ActionResult Edit(loan_table loan_table)
        {
            if (ModelState.IsValid)
            {
                var        getCustomer = ags.customer_profile_table.ToList();
                SelectList customers   = new SelectList(getCustomer, "id", "customerid");
                ViewBag.customerList = customers;

                var        getBank = ags.bank_table.ToList();
                SelectList banks   = new SelectList(getBank, "id", "bankname");
                ViewBag.bankList = banks;

                var        getloantype = ags.loantype_table.ToList();
                SelectList loantp      = new SelectList(getloantype, "id", "loan_type");
                ViewBag.loantypeList = loantp;

                var        empCategory   = ags.emp_category_table.Where(x => x.emp_category_id != "admin" && x.emp_category_id != "super_admin").ToList();
                SelectList empCategories = new SelectList(empCategory, "emp_category_id", "emp_category");
                ViewBag.empCategories = empCategories;

                var        employee  = ags.admin_table.ToList();
                SelectList employees = new SelectList(employee, "id", "name");
                ViewBag.employees = employees;

                var        ExtComment  = ags.external_comment_table.ToList();
                SelectList commentlist = new SelectList(ExtComment, "id", "externalcomment");
                ViewBag.commentList = commentlist;

                var allowedExtensions = new[] {
                    ".png", ".jpg", ".jpeg", ".doc", ".docx", ".pdf"
                };
                loan_table existing = ags.loan_table.Find(loan_table.id);
                string     partner  = existing.partnerid;

                existing.customerid     = loan_table.customerid;
                existing.bankid         = loan_table.bankid;
                existing.loantype       = loan_table.loantype;
                existing.requestloanamt = loan_table.requestloanamt;
                existing.followupdate   = loan_table.followupdate;

                if (existing.addedby == null)
                {
                    existing.addedby = Session["username"].ToString();
                }
                else
                {
                    existing.addedby = existing.addedby;
                }
                if (existing.datex == null)
                {
                    existing.datex = DateTime.Now.ToString();
                }
                else
                {
                    existing.datex = existing.datex;
                }

                ags.SaveChanges();

                int latestloanid = loan_table.id;

                ///Assigned Employee
                loan_track_table loan_track_employee = new loan_track_table();
                if (loan_table.employee != null)
                {
                    loan_track_employee.loanid     = latestloanid.ToString();
                    loan_track_employee.employeeid = loan_table.employee;
                    loan_track_employee.tracktime  = DateTime.Now.ToString();

                    if (loan_table.internalcomment != null)
                    {
                        loan_track_employee.internalcomment = loan_table.internalcomment;
                    }
                    if (loan_table.externalcomment != null)
                    {
                        loan_track_employee.externalcomment = loan_table.externalcomment;
                    }

                    loan_track_employee.datex        = DateTime.Now.ToString();
                    loan_track_employee.followupdate = loan_table.followupdate;
                    loan_track_employee.addedby      = Session["username"].ToString();
                    ags.loan_track_table.Add(loan_track_employee);
                    ags.SaveChanges();
                }

                /////Proof
                //proof_customer_table proof_customer_table = new proof_customer_table();

                //if (loan_table.proofid != null)
                //{
                //    proof_customer_table.customerid = loan_table.customerid;
                //    proof_customer_table.proofid = loan_table.proofid;
                //    proof_customer_table.proofans = loan_table.proofans;

                //    List<proof_customer_table> proofcus = ags.proof_customer_table.ToList();
                //    proofcus.ForEach(x => ags.proof_customer_table.Add(x));

                //    proof_customer_table.datex = DateTime.Now.ToString();
                //    proof_customer_table.addedby = Session["username"].ToString();
                //    ags.proof_customer_table.Add(proof_customer_table);
                //    ags.SaveChanges();
                //}


                vendor_track_table vendor_track = new vendor_track_table();
                if (loan_table.partnerid != null)
                {
                    vendor_track.loanid = latestloanid.ToString();
                    if (loan_table.partnerid != partner)
                    {
                        vendor_track.vendorid  = loan_table.partnerid;
                        vendor_track.tracktime = DateTime.Now.ToString();
                        vendor_track.comment   = "Assigned";

                        vendor_track.datex   = DateTime.Now.ToString();
                        vendor_track.addedby = Session["username"].ToString();
                        ags.vendor_track_table.Add(vendor_track);
                        ags.SaveChanges();
                    }
                }



                //assigned table
                assigned_table existing_data = ags.assigned_table.Where(x => x.loanid == loan_table.id.ToString()).FirstOrDefault();


                //existing_data.loanid = latestloanid.ToString();
                if (loan_table.employee != null)
                {
                    existing_data.assign_emp_id = loan_table.employee;
                }
                else
                {
                    existing_data.assign_emp_id = Session["userid"].ToString();
                }
                //if (loan_table.partnerid != null)
                //{
                //    existing_data.assign_vendor_id = loan_table.partnerid;
                //}
                //else
                //{
                //    existing_data.assign_vendor_id = Session["userid"].ToString();
                //}
                if (existing_data.addedby == null)
                {
                    existing_data.addedby = Session["username"].ToString();
                }
                else
                {
                    existing_data.addedby = existing_data.addedby;
                }
                if (existing_data.datex == null)
                {
                    existing_data.datex = DateTime.Now.ToString();
                }
                else
                {
                    existing_data.datex = existing_data.datex;
                }
                //loan assingned to notification table
                var employeename = ags.admin_table.Where(x => x.id.ToString() == loan_table.employee).FirstOrDefault();
                if (employeename != null)
                {
                    ags.notification_table.Add(new notification_table
                    {
                        notification = "Loan " + loan_table.customerid + " Assigned" + " to " + employeename.name,
                        seenstatus   = 1,
                        userid       = "super_admin",
                        addedby      = Session["username"].ToString(),
                        datex        = DateTime.Now.ToString(),
                    });
                }
                ags.notification_table.Add(new notification_table
                {
                    notification = "Loan (" + loan_table.customerid + ") Assigned" + " to you",
                    seenstatus   = 1,
                    userid       = loan_table.employee,
                    addedby      = Session["username"].ToString(),
                    datex        = DateTime.Now.ToString(),
                });
                ags.SaveChanges();

                return(RedirectToAction("salesloan"));
            }
            return(PartialView("~/Views/MobileSalesExecutive/SalesLoan/Edit.cshtml", loan_table));
        }
        public ActionResult Create(partner_customer obj)
        {
            if (Session["username"] == null || Session["userlevel"].ToString() != "partner")
            {
                return(this.RedirectToAction("MobileLogout", "Account"));
            }
            var        getloantype = ags.loantype_table.ToList();
            SelectList loantp      = new SelectList(getloantype, "id", "loan_type");

            ViewBag.loantypeList = loantp;
            if (ModelState.IsValid)
            {
                string vendorName = Session["username"].ToString();
                // var customer = (from u in ags.customer_profile_table where u.customerid == obj.customerid select u).FirstOrDefault();
                var vendor = (from u in ags.vendor_table where u.username == vendorName select u).FirstOrDefault();


                if (vendor != null)
                {
                    customer_profile_table customerprofile = new customer_profile_table();
                    customerprofile.name    = obj.name;
                    customerprofile.email   = obj.email;
                    customerprofile.phoneno = obj.phoneno;
                    customerprofile.datex   = DateTime.Now.ToString();
                    customerprofile.addedby = Session["username"].ToString();
                    ags.customer_profile_table.Add(customerprofile);
                    ags.SaveChanges();

                    int latestcustomerid = customerprofile.id;

                    customer_profile_table existing_Customer_Profile = ags.customer_profile_table.Find(customerprofile.id);
                    existing_Customer_Profile.customerid = latestcustomerid.ToString();
                    existing_Customer_Profile.password   = PasswordStorage.CreateHash(existing_Customer_Profile.customerid);
                    ags.SaveChanges();

                    loan_table loan = new loan_table();
                    loan.customerid      = latestcustomerid.ToString();
                    loan.partnerid       = vendor.id.ToString();
                    loan.loantype        = obj.loantype;
                    loan.requestloanamt  = obj.requestloanamt;
                    loan.disbursementamt = "0";
                    loan.loanamt         = "0";
                    loan.rateofinterest  = "0";
                    loan.loanstatus      = "Pending";
                    loan.datex           = DateTime.Now.ToString();
                    loan.addedby         = Session["username"].ToString();
                    ags.loan_table.Add(loan);
                    ags.SaveChanges();


                    //////////////////////////////////////
                    var    superadminid    = (from u in ags.admin_table where u.userrole == "super_admin" select u).FirstOrDefault();
                    string superemployeeid = superadminid.id.ToString();

                    int latestloanid = loan.id;

                    loan_track_table loan_track = new loan_track_table();
                    loan_track.loanid = latestloanid.ToString();
                    if (superemployeeid != null)
                    {
                        loan_track.employeeid = superemployeeid;
                        loan_track.tracktime  = DateTime.Now.ToString();
                    }
                    if (obj.internalcomment != null)
                    {
                        loan_track.internalcomment = obj.internalcomment;
                        loan_track.externalcomment = "Not Updated";
                    }
                    loan_track.datex   = DateTime.Now.ToString();
                    loan_track.addedby = Session["username"].ToString();
                    ags.loan_track_table.Add(loan_track);
                    ags.SaveChanges();


                    ///Assigned Employee

                    loan_track_table loan_track_employee = new loan_track_table();
                    if (Session["userid"] != null)
                    {
                        loan_track_employee.loanid          = latestloanid.ToString();
                        loan_track_employee.employeeid      = superemployeeid;
                        loan_track_employee.tracktime       = DateTime.Now.ToString();
                        loan_track_employee.internalcomment = "Vendor Assigned";
                        loan_track_employee.externalcomment = "Vendor Assigned";

                        loan_track_employee.datex   = DateTime.Now.ToString();
                        loan_track_employee.addedby = Session["username"].ToString();
                        ags.loan_track_table.Add(loan_track_employee);
                        ags.SaveChanges();
                    }


                    vendor_track_table vendor_track = new vendor_track_table();
                    if (Session["userid"] != null)
                    {
                        vendor_track.loanid    = latestloanid.ToString();
                        vendor_track.vendorid  = Session["userid"].ToString();
                        vendor_track.tracktime = DateTime.Now.ToString();
                        vendor_track.comment   = "Assigned to Super Admin";
                        vendor_track.datex     = DateTime.Now.ToString();
                        vendor_track.addedby   = Session["username"].ToString();
                        ags.vendor_track_table.Add(vendor_track);
                        ags.SaveChanges();
                    }


                    //assigned table

                    assigned_table assigned = new assigned_table();
                    assigned.loanid = latestloanid.ToString();
                    if (superemployeeid != null)
                    {
                        assigned.assign_emp_id = superemployeeid;
                    }
                    if (Session["userid"] != null)
                    {
                        assigned.assign_vendor_id = Session["userid"].ToString();
                    }
                    assigned.datex   = DateTime.Now.ToString();
                    assigned.addedby = Session["username"].ToString();
                    ags.assigned_table.Add(assigned);
                    ags.SaveChanges();

                    ////////////////////////////////////

                    return(RedirectToAction("Index"));
                }
                else
                {
                    TempData["AE"] = "This customer user name is already exist";
                    return(RedirectToAction("Index"));
                }
            }
            return(View("~/Views/MobileVendor/Create.cshtml", obj));
        }
Exemplo n.º 3
0
        public ActionResult Edit(loan_table loan_table)
        {
            if (ModelState.IsValid)
            {
                var        getCustomer = ags.customer_profile_table.ToList();
                SelectList customers   = new SelectList(getCustomer, "id", "customerid");
                ViewBag.customerList = customers;

                var        getVendor = ags.vendor_table.ToList();
                SelectList vendors   = new SelectList(getVendor, "id", "companyname");
                ViewBag.vendorList = vendors;

                var        getBank = ags.bank_table.ToList();
                SelectList banks   = new SelectList(getBank, "id", "bankname");
                ViewBag.bankList = banks;

                var        getloantype = ags.loantype_table.ToList();
                SelectList loantp      = new SelectList(getloantype, "id", "loan_type");
                ViewBag.loantypeList = loantp;

                var        empCategory   = ags.emp_category_table.Where(x => x.emp_category_id != "admin" && x.emp_category_id != "process_executive" && x.emp_category_id != "super_admin" && x.emp_category_id != "clientele" && x.emp_category_id != "partner").ToList();
                SelectList empCategories = new SelectList(empCategory, "emp_category_id", "emp_category");
                ViewBag.empCategories = empCategories;

                var        employee  = ags.admin_table.ToList();
                SelectList employees = new SelectList(employee, "id", "name");
                ViewBag.employees = employees;

                var        ExtComment  = ags.external_comment_table.ToList();
                SelectList commentlist = new SelectList(ExtComment, "id", "externalcomment");
                ViewBag.commentList = commentlist;

                //var allowedExtensions = new[] {
                //    ".png", ".jpg", ".jpeg",".doc",".docx",".pdf"
                //};
                loan_table existing = ags.loan_table.Find(loan_table.id);
                string     partner  = existing.partnerid;
                //if (existing.sactionedcopy == null)
                //{
                //    string BigfileName = Path.GetFileNameWithoutExtension(loan_table.sactionedCopyFile.FileName);
                //    string fileName = BigfileName.Substring(0, 1);
                //    string extension2 = Path.GetExtension(loan_table.sactionedCopyFile.FileName);
                //    string sactionedExtension = extension2.ToLower();
                //    if (allowedExtensions.Contains(sactionedExtension))
                //    {
                //        fileName = fileName + DateTime.Now.ToString("yyssmmfff") + sactionedExtension;
                //        loan_table.sactionedcopy = "~/sactionedcopyfile/" + fileName;
                //        fileName = Path.Combine(Server.MapPath("~/sactionedcopyfile/"), fileName);
                //        loan_table.sactionedCopyFile.SaveAs(fileName);
                //    }
                //    else
                //    {
                //        TempData["Message"] = "Only 'Jpg', 'png','jpeg','docx','doc','pdf' formats are alllowed..!";
                //        return RedirectToAction("managerloan");
                //    }
                //}


                //else if (existing.sactionedcopy != null && loan_table.sactionedcopy != null)
                //{
                //    if (loan_table.sactionedCopyFile != null)
                //    {
                //        string path = Server.MapPath(existing.sactionedcopy);
                //        FileInfo file = new FileInfo(path);
                //        if (file.Exists)
                //        {
                //            file.Delete();
                //        }
                //        string BigfileName = Path.GetFileNameWithoutExtension(loan_table.sactionedCopyFile.FileName);
                //        string fileName = BigfileName.Substring(0, 1);
                //        string extension2 = Path.GetExtension(loan_table.sactionedCopyFile.FileName);
                //        string sactionedExtension = extension2.ToLower();
                //        if (allowedExtensions.Contains(sactionedExtension))
                //        {
                //            fileName = fileName + DateTime.Now.ToString("yyssmmfff") + sactionedExtension;
                //            loan_table.sactionedcopy = "~/adminimage/" + fileName;
                //            fileName = Path.Combine(Server.MapPath("~/adminimage/"), fileName);
                //            loan_table.sactionedCopyFile.SaveAs(fileName);
                //        }
                //        else
                //        {
                //            TempData["Message"] = "Only 'Jpg', 'png','jpeg' images formats are alllowed..!";
                //            return RedirectToAction("managerloan");
                //        }

                //    }
                //    else
                //    {
                //        existing.sactionedcopy = existing.sactionedcopy;
                //    }
                //}
                //else
                //{
                //    existing.sactionedcopy = existing.sactionedcopy;
                //}

                ////ID copy file

                //if (existing.idcopy == null)
                //{
                //    string BigfileName = Path.GetFileNameWithoutExtension(loan_table.idCopyFile.FileName);
                //    string fileName = BigfileName.Substring(0, 1);
                //    string extension1 = Path.GetExtension(loan_table.idCopyFile.FileName);
                //    string idExtension = extension1.ToLower();
                //    if (allowedExtensions.Contains(idExtension))
                //    {
                //        fileName = fileName + DateTime.Now.ToString("yyssmmfff") + idExtension;
                //        loan_table.idcopy = "~/idcopyfile/" + fileName;
                //        fileName = Path.Combine(Server.MapPath("~/idcopyfile/"), fileName);
                //        loan_table.idCopyFile.SaveAs(fileName);
                //    }
                //    else
                //    {
                //        TempData["Message"] = "Only 'Jpg', 'png','jpeg','docx','doc','pdf' formats are alllowed..!";
                //        return RedirectToAction("managerloan");
                //    }
                //}


                //else if (existing.idcopy != null && loan_table.idcopy != null)
                //{
                //    if (loan_table.idCopyFile != null)
                //    {
                //        string path = Server.MapPath(existing.idcopy);
                //        FileInfo file = new FileInfo(path);
                //        if (file.Exists)
                //        {
                //            file.Delete();
                //        }
                //        string BigfileName = Path.GetFileNameWithoutExtension(loan_table.idCopyFile.FileName);
                //        string fileName = BigfileName.Substring(0, 1);
                //        string extension1 = Path.GetExtension(loan_table.idCopyFile.FileName);
                //        string idExtension = extension1.ToLower();
                //        if (allowedExtensions.Contains(idExtension))
                //        {
                //            fileName = fileName + DateTime.Now.ToString("yyssmmfff") + idExtension;
                //            loan_table.idcopy = "~/adminimage/" + fileName;
                //            fileName = Path.Combine(Server.MapPath("~/adminimage/"), fileName);
                //            loan_table.idCopyFile.SaveAs(fileName);
                //        }
                //        else
                //        {
                //            TempData["Message"] = "Only 'Jpg', 'png','jpeg' images formats are alllowed..!";
                //            return RedirectToAction("managerloan");
                //        }

                //    }
                //    else
                //    {
                //        existing.idcopy = existing.idcopy;
                //    }
                //}
                //else
                //{
                //    existing.idcopy = existing.idcopy;
                //}

                existing.customerid      = loan_table.customerid;
                existing.partnerid       = loan_table.partnerid;
                existing.bankid          = loan_table.bankid;
                existing.loantype        = loan_table.loantype;
                existing.requestloanamt  = loan_table.requestloanamt;
                existing.loanamt         = loan_table.loanamt;
                existing.disbursementamt = loan_table.disbursementamt;
                existing.rateofinterest  = loan_table.rateofinterest;
                //existing.followupdate = loan_table.followupdate;
                //existing.sactionedcopy = loan_table.sactionedcopy;
                //existing.idcopy = loan_table.idcopy;

                if (existing.addedby == null)
                {
                    existing.addedby = Session["username"].ToString();
                }
                else
                {
                    existing.addedby = existing.addedby;
                }
                if (existing.datex == null)
                {
                    existing.datex = DateTime.Now.ToString();
                }
                else
                {
                    existing.datex = existing.datex;
                }

                ags.SaveChanges();

                int latestloanid = loan_table.id;

                ///Assigned Employee
                loan_track_table loan_track_employee = new loan_track_table();
                if (loan_table.employee != null)
                {
                    loan_track_employee.loanid     = latestloanid.ToString();
                    loan_track_employee.employeeid = loan_table.employee;
                    loan_track_employee.tracktime  = DateTime.Now.ToString();

                    if (loan_table.internalcomment != null)
                    {
                        loan_track_employee.internalcomment = loan_table.internalcomment;
                    }
                    if (loan_table.externalcomment != null)
                    {
                        loan_track_employee.externalcomment = loan_table.externalcomment;
                    }

                    loan_track_employee.datex        = DateTime.Now.ToString();
                    loan_track_employee.followupdate = loan_table.followupdate;
                    loan_track_employee.addedby      = Session["username"].ToString();
                    ags.loan_track_table.Add(loan_track_employee);
                    ags.SaveChanges();
                }


                vendor_track_table vendor_track = new vendor_track_table();
                if (loan_table.partnerid != null)
                {
                    vendor_track.loanid = latestloanid.ToString();
                    if (loan_table.partnerid != partner)
                    {
                        vendor_track.vendorid  = loan_table.partnerid;
                        vendor_track.tracktime = DateTime.Now.ToString();
                        vendor_track.comment   = "Assigned";

                        vendor_track.datex   = DateTime.Now.ToString();
                        vendor_track.addedby = Session["username"].ToString();
                        ags.vendor_track_table.Add(vendor_track);
                        ags.SaveChanges();
                    }
                }



                //assigned table
                assigned_table existing_data = ags.assigned_table.Where(x => x.loanid == loan_table.id.ToString()).FirstOrDefault();


                //existing_data.loanid = latestloanid.ToString();
                if (loan_table.employee != null)
                {
                    existing_data.assign_emp_id = loan_table.employee;
                }
                else
                {
                    existing_data.assign_emp_id = Session["userid"].ToString();
                }
                if (loan_table.partnerid != null)
                {
                    existing_data.assign_vendor_id = loan_table.partnerid;
                }
                else
                {
                    existing_data.assign_vendor_id = Session["userid"].ToString();
                }
                if (existing_data.addedby == null)
                {
                    existing_data.addedby = Session["username"].ToString();
                }
                else
                {
                    existing_data.addedby = existing_data.addedby;
                }
                if (existing_data.datex == null)
                {
                    existing_data.datex = DateTime.Now.ToString();
                }
                else
                {
                    existing_data.datex = existing_data.datex;
                }
                //loan assingned to notification table
                var employeename = ags.admin_table.Where(x => x.id.ToString() == loan_table.employee).FirstOrDefault();
                if (employeename != null)
                {
                    ags.notification_table.Add(new notification_table
                    {
                        notification = "Loan " + loan_table.customerid + " Assigned" + " to " + employeename.name,
                        seenstatus   = 1,
                        userid       = "super_admin",
                        addedby      = Session["username"].ToString(),
                        datex        = DateTime.Now.ToString(),
                    });
                }
                ags.notification_table.Add(new notification_table
                {
                    notification = "Loan (" + loan_table.customerid + ") Assigned" + " to you",
                    seenstatus   = 1,
                    userid       = loan_table.employee,
                    addedby      = Session["username"].ToString(),
                    datex        = DateTime.Now.ToString(),
                });
                ags.SaveChanges();

                return(RedirectToAction("managerloan"));
            }
            return(PartialView("~/Views/Manager/ManagerLoan/Edit.cshtml", loan_table));
        }
Exemplo n.º 4
0
        public ActionResult Edit(loan_table loan_table, FormCollection form)
        {
            if (ModelState.IsValid)
            {
                var        getCustomer = ags.customer_profile_table.ToList();
                SelectList customers   = new SelectList(getCustomer, "id", "customerid");
                ViewBag.customerList = customers;

                var        getBank = ags.bank_table.ToList();
                SelectList banks   = new SelectList(getBank, "id", "bankname");
                ViewBag.bankList = banks;

                var        getloantype = ags.loantype_table.ToList();
                SelectList loantp      = new SelectList(getloantype, "id", "loan_type");
                ViewBag.loantypeList = loantp;

                var        empCategory   = ags.emp_category_table.Where(x => x.emp_category_id != "admin" && x.emp_category_id != "process_executive" && x.emp_category_id != "super_admin" && x.emp_category_id != "clientele" && x.emp_category_id != "partner").ToList();
                SelectList empCategories = new SelectList(empCategory, "emp_category_id", "emp_category");
                ViewBag.empCategories = empCategories;

                var        employee  = ags.admin_table.ToList();
                SelectList employees = new SelectList(employee, "id", "name");
                ViewBag.employees = employees;

                var        ExtComment  = ags.external_comment_table.ToList();
                SelectList commentlist = new SelectList(ExtComment, "id", "externalcomment");
                ViewBag.commentList = commentlist;

                List <proof_table> prooftable = ags.proof_table.ToList();
                ViewBag.prooflists = prooftable;

                var allowedExtensions = new[] {
                    ".png", ".jpg", ".jpeg", ".doc", ".docx", ".pdf"
                };
                loan_table existing = ags.loan_table.Find(loan_table.id);
                string     partner  = existing.partnerid;

                existing.customerid     = loan_table.customerid;
                existing.bankid         = loan_table.bankid;
                existing.loantype       = loan_table.loantype;
                existing.requestloanamt = loan_table.requestloanamt;
                existing.followupdate   = loan_table.followupdate;

                if (existing.addedby == null)
                {
                    existing.addedby = Session["username"].ToString();
                }
                else
                {
                    existing.addedby = existing.addedby;
                }
                if (existing.datex == null)
                {
                    existing.datex = DateTime.Now.ToString();
                }
                else
                {
                    existing.datex = existing.datex;
                }

                ags.SaveChanges();

                int latestloanid = loan_table.id;

                ///Assigned Employee
                loan_track_table loan_track_employee = new loan_track_table();
                if (loan_table.employee != null)
                {
                    loan_track_employee.loanid     = latestloanid.ToString();
                    loan_track_employee.employeeid = loan_table.employee;
                    loan_track_employee.tracktime  = DateTime.Now.ToString();

                    if (loan_table.internalcomment != null)
                    {
                        loan_track_employee.internalcomment = loan_table.internalcomment;
                    }
                    if (loan_table.externalcomment != null)
                    {
                        loan_track_employee.externalcomment = loan_table.externalcomment;
                    }

                    loan_track_employee.datex        = DateTime.Now.ToString();
                    loan_track_employee.followupdate = loan_table.followupdate;
                    loan_track_employee.addedby      = Session["username"].ToString();
                    ags.loan_track_table.Add(loan_track_employee);
                    ags.SaveChanges();
                }

                /////Proof

                string loanid_proof = loan_table.id.ToString();
                int    proof_customer_table_Count = ags.proof_customer_table.Where(x => x.customerid == loanid_proof).Count();
                //int proof_customer_table_Count = ags.customer_profile_table.Where(x => x.customerid == "1075").Count();
                var coumc = proof_customer_table_Count;
                if (proof_customer_table_Count != 0)
                {
                    var proofCount = ags.proof_table.ToList().Count();

                    if (proofCount != 0)
                    {
                        List <proof_customer_table> existing_proof = ags.proof_customer_table.ToList();
                        int k = 1;
                        foreach (var exitpf in existing_proof)
                        {
                            if (exitpf.customerid == loan_table.id.ToString())
                            {
                                var proofans  = "proofans" + k.ToString();
                                var questions = "questions" + k.ToString();
                                //string proofid = exitpf.id.ToString();
                                //proof_customer_table proofAns = ags.proof_customer_table.Where(x => x.id == exitpf.id).FirstOrDefault();
                                //loan id - in database its customerid
                                exitpf.customerid = loan_table.id.ToString();
                                exitpf.proofid    = form[questions].ToString();
                                exitpf.proofans   = form[proofans].ToString();
                                exitpf.datex      = DateTime.Now.ToString();
                                exitpf.addedby    = Session["username"].ToString();
                                //ags.proof_customer_table.Add(proof_customer_table);
                                ags.SaveChanges();
                                k++;
                            }
                        }
                    }
                }

                else if (proof_customer_table_Count == 0)
                {
                    var proofCount = ags.proof_table.ToList().Count();

                    if (proofCount != 0)
                    {
                        proof_customer_table proof_customer_table = new proof_customer_table();
                        for (int j = 1; j <= proofCount; j++)
                        {
                            var proofans  = "proofans" + j.ToString();
                            var questions = "questions" + j.ToString();

                            //loan id - in database its customerid
                            proof_customer_table.customerid = loan_table.id.ToString();
                            proof_customer_table.proofid    = form[questions].ToString();
                            proof_customer_table.proofans   = form[proofans].ToString();
                            proof_customer_table.datex      = DateTime.Now.ToString();
                            proof_customer_table.addedby    = Session["username"].ToString();
                            ags.proof_customer_table.Add(proof_customer_table);
                            ags.SaveChanges();
                        }
                    }
                }


                vendor_track_table vendor_track = new vendor_track_table();
                if (loan_table.partnerid != null)
                {
                    vendor_track.loanid = latestloanid.ToString();
                    if (loan_table.partnerid != partner)
                    {
                        vendor_track.vendorid  = loan_table.partnerid;
                        vendor_track.tracktime = DateTime.Now.ToString();
                        vendor_track.comment   = "Assigned";

                        vendor_track.datex   = DateTime.Now.ToString();
                        vendor_track.addedby = Session["username"].ToString();
                        ags.vendor_track_table.Add(vendor_track);
                        ags.SaveChanges();
                    }
                }



                //assigned table
                assigned_table existing_data = ags.assigned_table.Where(x => x.loanid == loan_table.id.ToString()).FirstOrDefault();


                //existing_data.loanid = latestloanid.ToString();
                if (loan_table.employee != null)
                {
                    existing_data.assign_emp_id = loan_table.employee;
                }
                else
                {
                    existing_data.assign_emp_id = Session["userid"].ToString();
                }
                //if (loan_table.partnerid != null)
                //{
                //    existing_data.assign_vendor_id = loan_table.partnerid;
                //}
                //else
                //{
                //    existing_data.assign_vendor_id = Session["userid"].ToString();
                //}
                if (existing_data.addedby == null)
                {
                    existing_data.addedby = Session["username"].ToString();
                }
                else
                {
                    existing_data.addedby = existing_data.addedby;
                }
                if (existing_data.datex == null)
                {
                    existing_data.datex = DateTime.Now.ToString();
                }
                else
                {
                    existing_data.datex = existing_data.datex;
                }
                //loan assingned to notification table
                var employeename = ags.admin_table.Where(x => x.id.ToString() == loan_table.employee).FirstOrDefault();
                if (employeename != null)
                {
                    ags.notification_table.Add(new notification_table
                    {
                        notification = "Loan " + loan_table.customerid + " Assigned" + " to " + employeename.name,
                        seenstatus   = 1,
                        userid       = "super_admin",
                        addedby      = Session["username"].ToString(),
                        datex        = DateTime.Now.ToString(),
                    });
                }
                ags.notification_table.Add(new notification_table
                {
                    notification = "Loan (" + loan_table.customerid + ") Assigned" + " to you",
                    seenstatus   = 1,
                    userid       = loan_table.employee,
                    addedby      = Session["username"].ToString(),
                    datex        = DateTime.Now.ToString(),
                });
                ags.SaveChanges();

                return(RedirectToAction("salesloan"));
            }
            return(PartialView("~/Views/SalesExecutive/SalesLoan/Edit.cshtml", loan_table));
        }
Exemplo n.º 5
0
        public ActionResult Create(loan_table obj)
        {
            if (Session["username"] == null || Session["userlevel"].ToString() != "sales_executive")
            {
                return(this.RedirectToAction("Logout", "Account"));
            }
            if (ModelState.IsValid)
            {
                var        getCustomer = ags.customer_profile_table.ToList();
                SelectList customers   = new SelectList(getCustomer, "id", "customerid");
                ViewBag.customerList = customers;

                var        getVendor = ags.vendor_table.ToList();
                SelectList vendors   = new SelectList(getVendor, "id", "companyname");
                ViewBag.vendorList = vendors;

                var        getBank = ags.bank_table.ToList();
                SelectList banks   = new SelectList(getBank, "id", "bankname");
                ViewBag.bankList = banks;



                List <emp_category_table> categoryList = ags.emp_category_table.ToList();
                ViewBag.empCategories = new SelectList(categoryList, "emp_category_id", "emp_category");

                var        getloantype = ags.loantype_table.ToList();
                SelectList loantp      = new SelectList(getloantype, "id", "loan_type");
                ViewBag.loantypeList = loantp;

                var        empCategory   = ags.emp_category_table.Where(x => x.emp_category_id != "admin" && x.emp_category_id != "process_executive" && x.emp_category_id != "super_admin" && x.emp_category_id != "clientele" && x.emp_category_id != "partner").ToList();
                SelectList empCategories = new SelectList(empCategory, "emp_category_id", "emp_category");
                ViewBag.empCategories = empCategories;

                var        employee  = ags.admin_table.ToList();
                SelectList employees = new SelectList(employee, "id", "name");
                ViewBag.employees = employees;

                // var usr = (from u in ags.loan_table where u. == obj.username select u).FirstOrDefault();
                var allowedExtensions = new[] {
                    ".png", ".jpg", ".jpeg", ".doc", ".docx", ".pdf"
                };
                string sactionedFileName = Path.GetFileNameWithoutExtension(obj.sactionedCopyFile.FileName);
                string fileName          = sactionedFileName.Substring(0, 1);
                string extension1        = Path.GetExtension(obj.sactionedCopyFile.FileName);
                string extension         = extension1.ToLower();
                if (allowedExtensions.Contains(extension))
                {
                    fileName          = fileName + DateTime.Now.ToString("yyssmmfff") + extension;
                    obj.sactionedcopy = "~/sactionedcopyfile/" + fileName;
                    fileName          = Path.Combine(Server.MapPath("~/sactionedcopyfile/"), fileName);
                    obj.sactionedCopyFile.SaveAs(fileName);
                }
                else
                {
                    TempData["Message"] = "Only 'Jpg','png','jpeg','docx','doc','pdf' images formats are alllowed..!";
                    return(RedirectToAction("salesloan"));
                }

                string idCopyFileName = Path.GetFileNameWithoutExtension(obj.idCopyFile.FileName);
                string idFileName     = idCopyFileName.Substring(0, 1);
                string extension2     = Path.GetExtension(obj.idCopyFile.FileName);
                string idExtension    = extension2.ToLower();
                if (allowedExtensions.Contains(idExtension))
                {
                    idFileName = idFileName + DateTime.Now.ToString("yyssmmfff") + extension;
                    obj.idcopy = "~/idcopyfile/" + idFileName;
                    idFileName = Path.Combine(Server.MapPath("~/idcopyfile/"), idFileName);
                    obj.idCopyFile.SaveAs(idFileName);
                }
                else
                {
                    TempData["Message"] = "Only 'Jpg','png','jpeg','docx','doc','pdf' formats are alllowed..!";
                    return(RedirectToAction("salesloan"));
                }
                loan_table loan = new loan_table();
                loan.customerid      = obj.customerid;
                loan.partnerid       = obj.partnerid;
                loan.bankid          = obj.bankid;
                loan.loantype        = obj.loantype;
                loan.loanamt         = obj.loanamt;
                loan.disbursementamt = obj.disbursementamt;
                loan.rateofinterest  = obj.rateofinterest;
                loan.sactionedcopy   = obj.sactionedcopy;
                loan.idcopy          = obj.idcopy;
                loan.datex           = DateTime.Now.ToString();
                loan.addedby         = Session["username"].ToString();
                ags.loan_table.Add(loan);
                ags.SaveChanges();

                int latestloanid = loan.id;

                loan_track_table loan_track = new loan_track_table();
                loan_track.loanid = latestloanid.ToString();
                if (Session["userid"] != null)
                {
                    loan_track.employeeid = Session["userid"].ToString();
                    loan_track.tracktime  = DateTime.Now.ToString();
                }
                //if (obj.partnerid != null)
                //{
                //    loan_track.vendorid = obj.partnerid;
                //    loan_track.vendortracktime = DateTime.Now.ToString();

                //}
                if (obj.internalcomment != null)
                {
                    loan_track.internalcomment = obj.internalcomment;
                }
                if (obj.externalcomment != null)
                {
                    loan_track.externalcomment = obj.externalcomment;
                }
                loan_track.datex   = DateTime.Now.ToString();
                loan_track.addedby = Session["username"].ToString();
                ags.loan_track_table.Add(loan_track);
                ags.SaveChanges();


                ///Assigned Employee

                loan_track_table loan_track_employee = new loan_track_table();
                if (obj.employee != null)
                {
                    loan_track_employee.loanid     = latestloanid.ToString();
                    loan_track_employee.employeeid = obj.employee;
                    loan_track_employee.tracktime  = DateTime.Now.ToString();
                    //if (obj.partnerid != null)
                    //{
                    //    loan_track.vendorid = obj.partnerid;
                    //    loan_track.vendortracktime = DateTime.Now.ToString();

                    //}
                    loan_track_employee.internalcomment = "Assigned";
                    loan_track_employee.externalcomment = "Assigned";

                    loan_track_employee.datex   = DateTime.Now.ToString();
                    loan_track_employee.addedby = Session["username"].ToString();
                    ags.loan_track_table.Add(loan_track_employee);
                    ags.SaveChanges();
                }


                vendor_track_table vendor_track = new vendor_track_table();
                if (obj.partnerid != null)
                {
                    vendor_track.loanid    = latestloanid.ToString();
                    vendor_track.vendorid  = obj.partnerid;
                    vendor_track.tracktime = DateTime.Now.ToString();
                    vendor_track.comment   = "Assigned";
                    vendor_track.datex     = DateTime.Now.ToString();
                    vendor_track.addedby   = Session["username"].ToString();
                    ags.vendor_track_table.Add(vendor_track);
                    ags.SaveChanges();
                }


                //assigned table

                assigned_table assigned = new assigned_table();
                assigned.loanid = latestloanid.ToString();
                if (obj.employee != null)
                {
                    assigned.assign_emp_id = obj.employee;
                }
                else
                {
                    assigned.assign_emp_id = Session["userid"].ToString();
                }
                if (obj.partnerid != null)
                {
                    assigned.assign_vendor_id = obj.partnerid;
                }
                assigned.datex   = DateTime.Now.ToString();
                assigned.addedby = Session["username"].ToString();
                ags.assigned_table.Add(assigned);
                ags.SaveChanges();
                return(RedirectToAction("salesloan"));
            }
            else
            {
                TempData["AE"] = "Something went wrong";
                return(RedirectToAction("salesloan"));
            }
        }
Exemplo n.º 6
0
        public ActionResult Create(loan_table obj)
        {
            if (Session["username"] == null || Session["userlevel"].ToString() != "admin")
            {
                return(this.RedirectToAction("Logout", "Account"));
            }
            if (ModelState.IsValid)
            {
                var        getCustomer = ags.customer_profile_table.ToList();
                SelectList customers   = new SelectList(getCustomer, "id", "customerid");
                ViewBag.customerList = customers;

                var        getVendor = ags.vendor_table.ToList();
                SelectList vendors   = new SelectList(getVendor, "id", "companyname");
                ViewBag.vendorList = vendors;

                var        getBank = ags.bank_table.ToList();
                SelectList banks   = new SelectList(getBank, "id", "bankname");
                ViewBag.bankList = banks;

                var        getloantype = ags.loantype_table.ToList();
                SelectList loantp      = new SelectList(getloantype, "id", "loan_type");
                ViewBag.loantypeList = loantp;

                var        empCategory   = ags.emp_category_table.Where(x => x.emp_category_id != "admin" && x.emp_category_id != "process_executive" && x.emp_category_id != "super_admin" && x.emp_category_id != "clientele" && x.emp_category_id != "partner").ToList();
                SelectList empCategories = new SelectList(empCategory, "emp_category_id", "emp_category");
                ViewBag.empCategories = empCategories;

                var        employee  = ags.admin_table.ToList();
                SelectList employees = new SelectList(employee, "id", "name");
                ViewBag.employees = employees;

                var        ExtComment  = ags.external_comment_table.ToList();
                SelectList commentlist = new SelectList(ExtComment, "id", "externalcomment");
                ViewBag.commentList = commentlist;

                // var usr = (from u in ags.loan_table where u. == obj.username select u).FirstOrDefault();
                var allowedExtensions = new[] {
                    ".png", ".jpg", ".jpeg", ".doc", ".docx", ".pdf"
                };
                if (obj.propertyDocumentsFile != null)
                {
                    string propertyDocumentsFile = Path.GetFileNameWithoutExtension(obj.propertyDocumentsFile.FileName);
                    string propertyFileName      = propertyDocumentsFile.Substring(0, 1);
                    string extension3            = Path.GetExtension(obj.propertyDocumentsFile.FileName);
                    string propertyExtension     = extension3.ToLower();
                    if (allowedExtensions.Contains(propertyExtension))
                    {
                        propertyFileName      = propertyFileName + DateTime.Now.ToString("yyssmmfff") + extension3;
                        obj.propertydocuments = "~/propertyFile/" + propertyFileName;
                        propertyFileName      = Path.Combine(Server.MapPath("~/propertyFile/"), propertyFileName);
                        obj.propertyDocumentsFile.SaveAs(propertyFileName);
                    }
                    else
                    {
                        TempData["Message"] = "Only 'Jpg','png','jpeg','docx','doc','pdf' formats are alllowed..!";
                        return(View());
                    }
                }
                loan_table loan = new loan_table();
                loan.customerid        = obj.customerid;
                loan.partnerid         = obj.partnerid;
                loan.bankid            = obj.bankid;
                loan.loantype          = obj.loantype;
                loan.loanamt           = "0";
                loan.requestloanamt    = obj.requestloanamt;
                loan.disbursementamt   = "0";
                loan.propertydocuments = obj.propertydocuments;
                loan.propertydetails   = obj.propertydetails;
                if (!string.IsNullOrEmpty(obj.loanstatus))
                {
                    loan.loanstatus = obj.loanstatus;
                }
                else
                {
                    loan.loanstatus = "Pending";
                }
                loan.datex   = DateTime.Now.ToString();
                loan.addedby = Session["username"].ToString();
                ags.loan_table.Add(loan);
                ags.SaveChanges();

                int latestloanid = loan.id;

                loan_track_table loan_track = new loan_track_table();
                loan_track.loanid = latestloanid.ToString();
                if (Session["userid"] != null)
                {
                    loan_track.employeeid = Session["userid"].ToString();
                    loan_track.tracktime  = DateTime.Now.ToString();
                }
                if (obj.internalcomment != null)
                {
                    loan_track.internalcomment = obj.internalcomment;
                }
                if (obj.externalcomment != null)
                {
                    loan_track.externalcomment = obj.externalcomment;
                }
                loan_track.datex   = DateTime.Now.ToString();
                loan_track.addedby = Session["username"].ToString();
                ags.loan_track_table.Add(loan_track);
                ags.SaveChanges();


                ///Assigned Employee

                loan_track_table loan_track_employee = new loan_track_table();
                if (obj.employee != null)
                {
                    loan_track_employee.loanid          = latestloanid.ToString();
                    loan_track_employee.employeeid      = obj.employee;
                    loan_track_employee.followupdate    = obj.followupdate;
                    loan_track_employee.tracktime       = DateTime.Now.ToString();
                    loan_track_employee.internalcomment = "Assigned";
                    loan_track_employee.externalcomment = "Assigned";

                    loan_track_employee.datex   = DateTime.Now.ToString();
                    loan_track_employee.addedby = Session["username"].ToString();
                    ags.loan_track_table.Add(loan_track_employee);
                    ags.SaveChanges();
                }


                vendor_track_table vendor_track = new vendor_track_table();
                if (obj.partnerid != null)
                {
                    vendor_track.loanid    = latestloanid.ToString();
                    vendor_track.vendorid  = obj.partnerid;
                    vendor_track.tracktime = DateTime.Now.ToString();
                    vendor_track.comment   = "Assigned";
                    vendor_track.datex     = DateTime.Now.ToString();
                    vendor_track.addedby   = Session["username"].ToString();
                    ags.vendor_track_table.Add(vendor_track);
                    ags.SaveChanges();
                }


                //assigned table

                assigned_table assigned = new assigned_table();
                assigned.loanid = latestloanid.ToString();
                if (obj.employee != null)
                {
                    assigned.assign_emp_id = obj.employee;
                }
                else
                {
                    assigned.assign_emp_id = Session["userid"].ToString();
                }
                if (obj.partnerid != null)
                {
                    assigned.assign_vendor_id = obj.partnerid;
                }
                assigned.datex   = DateTime.Now.ToString();
                assigned.addedby = Session["username"].ToString();
                ags.assigned_table.Add(assigned);

                var employeename = ags.admin_table.Where(x => x.username == Session["username"].ToString()).FirstOrDefault();
                // Loan notification to Super admin and Admin
                ags.notification_table.Add(new notification_table
                {
                    notification = "New Loan has Created for " + obj.customerid + " By " + employeename.name + "(Admin)",
                    seenstatus   = 1,
                    userid       = employeename.username,
                    addedby      = Session["username"].ToString(),
                    datex        = DateTime.Now.ToString(),
                });

                ags.notification_table.Add(new notification_table
                {
                    notification = "New Loan has Created for " + obj.customerid + " By You",
                    seenstatus   = 1,
                    userid       = employeename.username,
                    addedby      = Session["username"].ToString(),
                    datex        = DateTime.Now.ToString(),
                });

                ags.SaveChanges();
                return(RedirectToAction("Loan"));
            }
            else
            {
                TempData["AE"] = "Something went wrong";
                return(RedirectToAction("Loan"));
            }
        }