Example #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            customer_profile_table customer_profile_table = ags.customer_profile_table.Find(id);
            string   path = Server.MapPath(customer_profile_table.profileimg);
            FileInfo file = new FileInfo(path);

            if (file.Exists)
            {
                file.Delete();
            }
            ags.customer_profile_table.Remove(customer_profile_table);
            ags.SaveChanges();
            return(RedirectToAction("Customer"));
        }
        public ActionResult Password(ChangePassword changePwd)
        {
            if (ModelState.IsValid)
            {
                string userid = Session["userid"].ToString();
                if (userid != null)
                {
                    customer_profile_table existing = ags.customer_profile_table.Where(x => x.id.ToString() == userid).FirstOrDefault();

                    var  password       = existing.password.ToString();
                    var  oldPassword    = changePwd.password;
                    var  newPassword    = changePwd.newpassword;
                    var  retypePassword = changePwd.retypepassword;
                    bool result         = PasswordStorage.VerifyPassword(oldPassword, password);
                    if (result)
                    {
                        if (newPassword == retypePassword)
                        {
                            existing.password = PasswordStorage.CreateHash(newPassword);
                        }
                        else
                        {
                            TempData["NotEqual"] = "<script>alert('password dosen't match');</script>";
                            return(RedirectToAction("Index", "Clientele"));
                        }
                    }
                    else
                    {
                        TempData["logAgain"] = "Oops.! Please Provide Valid Credentials.";
                        return(RedirectToAction("ClientLogout", "Account"));
                    }
                    ags.SaveChanges();



                    return(RedirectToAction("Index", "Clientele"));
                }
                else
                {
                    TempData["logAgain"] = "Oops.! Something Went Wrong.";
                    return(RedirectToAction("ClientLogout", "Account"));
                }
            }
            return(RedirectToAction("Index", "Clientele"));
        }
        public ActionResult EditProfile(int?Id)
        {
            if (Session["username"] == null || Session["userlevel"].ToString() != "clientele")
            {
                return(this.RedirectToAction("ClientLogout", "Account"));
            }
            if (Id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            customer_profile_table customer_profile_table = ags.customer_profile_table.Find(Id);

            if (customer_profile_table == null)
            {
                return(HttpNotFound());
            }
            return(PartialView(customer_profile_table));
        }
        public ActionResult Edit(int?Id)
        {
            if (Session["username"] == null || Session["userlevel"].ToString() != "process_team")
            {
                return(this.RedirectToAction("Logout", "Account"));
            }
            if (Id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            customer_profile_table customer_profile_table = ags.customer_profile_table.Find(Id);

            if (customer_profile_table == null)
            {
                return(HttpNotFound());
            }
            return(PartialView("~/Views/ProcessTeam/ProcessTeam/Edit.cshtml", customer_profile_table));
        }
        public ActionResult EditProfile(customer_profile_table customer_profile_table, FormCollection form)
        {
            if (ModelState.IsValid)
            {
                var allowedExtensions = new[] {
                    ".Jpg", ".png", ".jpg", ".jpeg"
                };
                customer_profile_table existing = ags.customer_profile_table.Find(customer_profile_table.id);
                var password    = existing.password.ToString();
                var newPassword = customer_profile_table.password.ToString();


                if (existing.profileimg == null && customer_profile_table.ImageFile != null)
                {
                    string BigfileName = Path.GetFileNameWithoutExtension(customer_profile_table.ImageFile.FileName);
                    string fileName    = BigfileName.Substring(0, 1);
                    string extension1  = Path.GetExtension(customer_profile_table.ImageFile.FileName);
                    string extension   = extension1.ToLower();
                    if (allowedExtensions.Contains(extension))
                    {
                        fileName = fileName + DateTime.Now.ToString("yyssmmfff") + extension;
                        customer_profile_table.profileimg = "~/customerImage/" + fileName;
                        fileName = Path.Combine(Server.MapPath("~/customerImage/"), fileName);
                        customer_profile_table.ImageFile.SaveAs(fileName);
                    }
                    else
                    {
                        TempData["Message"] = "Only 'Jpg', 'png','jpeg' images formats are alllowed..!";
                        return(RedirectToAction("Index", "Clientele"));
                    }
                }


                else if (existing.profileimg != null && customer_profile_table.profileimg != null)
                {
                    if (customer_profile_table.ImageFile != null)
                    {
                        string   path = Server.MapPath(existing.profileimg);
                        FileInfo file = new FileInfo(path);
                        if (file.Exists)
                        {
                            file.Delete();
                        }
                        string BigfileName = Path.GetFileNameWithoutExtension(customer_profile_table.ImageFile.FileName);
                        string fileName    = BigfileName.Substring(0, 1);
                        string extension1  = Path.GetExtension(customer_profile_table.ImageFile.FileName);
                        string extension   = extension1.ToLower();
                        if (allowedExtensions.Contains(extension))
                        {
                            fileName = fileName + DateTime.Now.ToString("yyssmmfff") + extension;
                            customer_profile_table.profileimg = "~/customerImage/" + fileName;
                            fileName = Path.Combine(Server.MapPath("~/customerImage/"), fileName);
                            customer_profile_table.ImageFile.SaveAs(fileName);
                        }
                        else
                        {
                            TempData["Message"] = "Only 'Jpg', 'png','jpeg' images formats are alllowed..!";
                            return(RedirectToAction("Index", "Clientele"));
                        }
                    }
                    else
                    {
                        existing.profileimg = existing.profileimg;
                    }
                }
                else
                {
                    existing.profileimg = existing.profileimg;
                }
                existing.name         = customer_profile_table.name;
                existing.email        = customer_profile_table.email;
                existing.phoneno      = customer_profile_table.phoneno;
                existing.weddingdate  = customer_profile_table.weddingdate;
                existing.dob          = customer_profile_table.dob;
                existing.address      = customer_profile_table.address;
                existing.alterphoneno = customer_profile_table.alterphoneno;

                if (existing.customerid != customer_profile_table.customerid)
                {
                    var userCount = (from u in ags.admin_table where u.username == customer_profile_table.customerid select u).Count();
                    if (userCount == 0)
                    {
                        existing.customerid = customer_profile_table.customerid;
                    }
                    else
                    {
                        //existing.username = admin_table.username;
                        TempData["AE"] = "This user name is already exist";
                        //return PartialView("Edit", "SuperAdmin");
                        return(RedirectToAction("Index", "Clientele"));
                    }
                }


                existing.profileimg = customer_profile_table.profileimg;



                if (existing.datex == null)
                {
                    existing.datex = DateTime.Now.ToString();
                }
                else
                {
                    existing.datex = existing.datex;
                }
                if (password.Equals(newPassword))
                {
                    existing.password = customer_profile_table.password;
                }
                else
                {
                    existing.password = PasswordStorage.CreateHash(customer_profile_table.password);
                }

                ags.SaveChanges();
                return(RedirectToAction("Index", "Clientele"));
            }
            return(RedirectToAction("Index", "Clientele"));
        }
Example #6
0
        public ActionResult Create(customer_profile_table obj)
        {
            if (Session["username"] == null || Session["userlevel"].ToString() != "super_admin")
            {
                return(this.RedirectToAction("Logout", "Account"));
            }
            if (ModelState.IsValid)
            {
                var usr = (from u in ags.customer_profile_table where u.customerid == obj.customerid select u).FirstOrDefault();
                var allowedExtensions = new[] {
                    ".Jpg", ".png", ".jpg", ".jpeg"
                };
                var customer = (from u in ags.customer_profile_table where u.customerid == obj.customerid select u).FirstOrDefault();


                if (customer == null)
                {
                    //bool filename = string.IsNullOrEmpty(obj.ImageFile.FileName);
                    if (obj.ImageFile != null)
                    {
                        string BigfileName = Path.GetFileNameWithoutExtension(obj.ImageFile.FileName);
                        string fileName    = BigfileName.Substring(0, 1);
                        string extension1  = Path.GetExtension(obj.ImageFile.FileName);

                        string extension = extension1.ToLower();
                        if (allowedExtensions.Contains(extension))
                        {
                            fileName       = fileName + DateTime.Now.ToString("yyssmmfff") + extension;
                            obj.profileimg = "~/customerImage/" + fileName;
                            fileName       = Path.Combine(Server.MapPath("~/customerImage/"), fileName);
                            obj.ImageFile.SaveAs(fileName);
                        }
                        else
                        {
                            TempData["Message"] = "Only 'Jpg', 'png','jpeg' images formats are alllowed..!";
                            return(RedirectToAction("Customer"));
                        }
                    }
                    if (!string.IsNullOrEmpty(obj.password))
                    {
                        obj.password = PasswordStorage.CreateHash(obj.password);
                    }
                    ags.customer_profile_table.Add(new customer_profile_table
                    {
                        customerid   = obj.customerid,
                        name         = obj.name,
                        email        = obj.email,
                        phoneno      = obj.phoneno,
                        alterphoneno = obj.alterphoneno,
                        dob          = obj.dob,
                        weddingdate  = obj.weddingdate,
                        profileimg   = obj.profileimg,
                        password     = obj.password,
                        address      = obj.address,
                        datex        = DateTime.Now.ToString(),
                        addedby      = Session["username"].ToString()
                    });
                    ags.notification_table.Add(new notification_table
                    {
                        notification = "New Customer " + obj.name + " has Created By Super Admin",
                        seenstatus   = 1,
                        userid       = "super_admin",
                        addedby      = Session["username"].ToString(),
                        datex        = DateTime.Now.ToString(),
                    });
                    ags.SaveChanges();
                    return(RedirectToAction("Customer", "Customer"));
                }
                else
                {
                    TempData["AE"] = "This customer user name is already exist";
                    return(RedirectToAction("Customer"));
                }
            }
            return(View(obj));
        }
        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));
        }