public ActionResult HtmlBeginForm(CustomerModel model)
        {
            customerdbEntities2 db = new customerdbEntities2();
            string message         = string.Empty;
            bool   status          = false;

            try
            {
                if (model.DoB.Value.Year <= 2000)
                {
                    if (!model.CustomerId.HasValue)
                    {
                        //var filename = Server.MapPath("~/CustomerImages/" + model.ImageFile.FileName);
                        string filename = Path.GetFileNameWithoutExtension(model.ImageFile.FileName);
                        if (model.ImageFile.ContentLength < 1000000)
                        {
                            if (model.ImageFile.ContentType == "image/png" || model.ImageFile.ContentType == "image/jpeg" || model.ImageFile.ContentType == "image/jpg")
                            {
                                model.ImagePath = "~/CustomerImages/";
                                model.ImageFile.SaveAs(Path.Combine(Server.MapPath("~/CustomerImages/"), filename));
                                //model.ImageFile.SaveAs(filename);
                                db.SaveCustomerdb(model.FirstName, model.LastName, model.Gender, model.DoB, model.Email, model.PhoneNumber, model.Address, model.City, model.State, model.Pincode.ToString(), null, model.ImageFile.FileName);
                                message = "Record saved successfully.";
                                status  = true;
                            }
                            else
                            {
                                Response.Write("<h1 style='color: Tomato;'><marquee>Upload Failed!Supports Only JPEG and PNG Format.</marquee></h1>");
                            }
                        }
                        else
                        {
                            Response.Write("<h1 style='color: Tomato;'><marquee>Upload Failed!File size must be below 1Mb.</marquee></h1>");
                        }
                    }
                    else
                    {
                        if (model.ImageFile == null)
                        {
                            var fileNames = Path.GetFileName(model.ImagePath);
                            db.UpdateCustomerdb(model.CustomerId, model.FirstName, model.LastName, model.Gender, model.DoB, model.Email, model.PhoneNumber, model.Address, model.City, model.State, model.Pincode.ToString(), null, fileNames);
                            message = "Record updated successfully.";
                            status  = true;
                        }

                        else
                        {
                            if (model.ImageFile.ContentLength < 1000000)
                            {
                                if (model.ImageFile.ContentType == "image/png" || model.ImageFile.ContentType == "image/jpeg" || model.ImageFile.ContentType == "image/jpg")
                                {
                                    db.UpdateCustomerdb(model.CustomerId, model.FirstName, model.LastName, model.Gender, model.DoB, model.Email, model.PhoneNumber, model.Address, model.City, model.State, model.Pincode.ToString(), null, model.ImageFile.FileName);
                                    message = "Record updated successfully.";
                                    status  = true;
                                }
                                else
                                {
                                    Response.Write("<h1 style='color: Tomato;'><marquee>Upload Failed!Supports Only JPEG and PNG Format.</marquee></h1>");
                                }
                            }
                            else
                            {
                                Response.Write("<h1 style='color: Tomato;'><marquee>Upload Failed!File size must be below 1Mb.</marquee></h1>");
                            }
                        }
                    }
                }
                else
                {
                    message = "Date error, Please try again.";
                    status  = false;
                }
                List <CustomerModel> cusDetailsList = new List <CustomerModel>();
                var cus = db.GetCustomerdb(null).ToList();
                foreach (var item in cus)
                {
                    cusDetailsList.Add(new CustomerModel()
                    {
                        FirstName   = item.FirstName,
                        LastName    = item.LastName,
                        Gender      = item.Gender.Value,
                        DoB         = item.DoB,
                        Email       = item.Email,
                        PhoneNumber = item.PhoneNumber,
                        Address     = item.Address,
                        City        = item.City,
                        State       = item.State,
                        Pincode     = Convert.ToInt32(item.Pincode),
                        CustomerId  = item.CustomerId,
                        ImagePath   = item.ImagePath
                    });
                }
                model.cusDetailsList = cusDetailsList;
            }
            catch (Exception ex)
            {
                string error = ex.Message;
                message = "ERROR! Please Try Again";
                status  = false;
            }

            return(RedirectToAction("DisplayCustomerDetailsList"));
        }
        public ActionResult Index(CustomerModel model)
        {
            customerdbEntities2 db = new customerdbEntities2();
            string message         = string.Empty;
            bool   status          = false;

            try
            {
                if (model.DoB.Value.Year <= 2000)
                {
                    if (!model.CustomerId.HasValue)
                    {
                        db.SaveCustomerdb(model.FirstName, model.LastName, model.Gender, model.DoB, model.Email, model.PhoneNumber, model.Address, model.City, model.State, model.Pincode.ToString(), null, null);
                        message = "Record saved successfully.";
                        status  = true;
                    }
                    else
                    {
                        db.UpdateCustomerdb(model.CustomerId, model.FirstName, model.LastName, model.Gender, model.DoB, model.Email, model.PhoneNumber, model.Address, model.City, model.State, model.Pincode.ToString(), null, model.ImagePath);
                        message = "Record updated successfully.";
                        status  = true;
                    }
                }
                else
                {
                    message = "Date error, Please try again.";
                    status  = false;
                }
                List <CustomerModel> cusDetailsList = new List <CustomerModel>();
                var cus = db.GetCustomerdb(null).ToList();
                foreach (var item in cus)
                {
                    cusDetailsList.Add(new CustomerModel()
                    {
                        FirstName   = item.FirstName,
                        LastName    = item.LastName,
                        Gender      = item.Gender.Value,
                        DoB         = item.DoB,
                        Email       = item.Email,
                        PhoneNumber = item.PhoneNumber,
                        Address     = item.Address,
                        City        = item.City,
                        State       = item.State,
                        Pincode     = Convert.ToInt32(item.Pincode),
                        CustomerId  = item.CustomerId
                    });
                }
                model.cusDetailsList = cusDetailsList;
            }
            catch (Exception ex)
            {
                string error = ex.Message;
                message = "ERROR! Please Try Again";
                status  = false;
            }
            return(Json(new
            {
                status = status,
                message = message,
                content = RenderRazorViewToString("_PartialCustomerDetailsList", model)
            }
                        ));
        }