public ActionResult FollowupMasterView(int id)//id=cust id
        {
            FollowUpModel model = new FollowUpModel();

            try
            {
                List <FollowUpModel> cusDetailsList = new List <FollowUpModel>();
                customerdbEntities2  db             = new customerdbEntities2();
                var cus = db.CustomerFollowUpsGet(null, id).ToList();
                foreach (var item in cus)
                {
                    cusDetailsList.Add(new FollowUpModel()
                    {
                        FollowUpDate     = item.FollowUpDate.Value,
                        FollowUpType     = item.FollowUpType.Value,
                        Comments         = item.Comments,
                        Status           = item.Status.Value,
                        NextFollowUpDate = item.NextFollowUpDate.Value,
                        FollowUpId       = item.FollowUpId,
                        Cid = item.CustomerId.Value
                    });
                }
                model.cusDetailsList = cusDetailsList;
                var Details = db.GetCustomerdb(id).FirstOrDefault();
                model.FirstName = Details.FirstName;
            }
            catch (Exception ex)
            {
                string error = ex.Message;
            }

            return(View(model));
        }
        public ActionResult DeleteCustomerFollowup(int id, int cid)//id=followupid cid=custid
        {
            customerdbEntities2 db    = new customerdbEntities2();
            FollowUpModel       model = new FollowUpModel();
            string message            = string.Empty;
            bool   status             = false;

            try
            {
                var Cusdet = db.CustomerFollowUpsDelete(id);
                var cus    = db.CustomerFollowUpsGet(null, cid).ToList();
                List <FollowUpModel> cusDetailsList = new List <FollowUpModel>();
                foreach (var item in cus)
                {
                    cusDetailsList.Add(new FollowUpModel()
                    {
                        FollowUpDate     = item.FollowUpDate.Value,
                        FollowUpType     = item.FollowUpType.Value,
                        Comments         = item.Comments,
                        Status           = item.Status.Value,
                        NextFollowUpDate = item.NextFollowUpDate.Value,
                        FollowUpId       = item.FollowUpId,
                        Cid = item.CustomerId.Value
                    });
                }
                model.cusDetailsList = cusDetailsList;
                message = "Record deleted successfully.";
                status  = true;
            }
            catch (Exception ex)
            {
                string error = ex.Message;
                message = "Record not deleted, try again.";
                status  = false;
            }
            return(Json(new
            {
                status = status,
                message = message,
                content = RenderRazorViewToString("FollowUpCustomerDetailsList", model)
            }));

            //public ActionResult DeletePopUp()
            //{
            //    return View();
            //}
        }
        public ActionResult EditCustomerFollowup(int id)//id=followupid
        {
            customerdbEntities2 db = new customerdbEntities2();

            FollowUpModel model = new FollowUpModel();

            if (id != null)
            {
                var Cusdet = db.CustomerFollowUpsGet(id, null).FirstOrDefault();
                if (Cusdet != null)
                {
                    model.FollowUpId       = Cusdet.FollowUpId;
                    model.FollowUpDate     = Cusdet.FollowUpDate.Value;
                    model.FollowUpType     = Cusdet.FollowUpType.Value;
                    model.Comments         = Cusdet.Comments;
                    model.Status           = Cusdet.Status.Value;
                    model.NextFollowUpDate = Cusdet.NextFollowUpDate;
                    model.Cid = Cusdet.CustomerId.Value;
                }
            }
            return(PartialView("EditCustomerFollowupForm", model));
        }
        public ActionResult EditCustomerFollowup(FollowUpModel model)//id=customerid
        {
            customerdbEntities2 db = new customerdbEntities2();
            string        message  = string.Empty;
            bool          status   = false;
            FollowUpModel fc       = new FollowUpModel();


            try
            {
                if (model.FollowUpDate.Value <= DateTime.Now)
                {
                    if (model.NextFollowUpDate > model.FollowUpDate)
                    {
                        if (!model.FollowUpId.HasValue)
                        {
                            //db.CustomerFollowUpsInsert(model.FollowUpDate, model.FollowUpType, model.Comments, model.Status, model.NextFollowUpDate, null, id);
                            //message = "Record saved successfully.";
                            //status = true;
                        }
                        else
                        {
                            db.CustomerFollowUpsUpdate(model.FollowUpId, model.Cid, model.FollowUpDate, model.FollowUpType, model.Comments, model.Status, model.NextFollowUpDate, null);
                            message = "Record updated successfully.";
                            status  = true;
                        }
                    }
                    else
                    {
                        message = "Next FollowUp Date Must Be Greater.";
                    }
                }

                else
                {
                    message = "Date error, Please try again.";
                    status  = false;
                }

                List <FollowUpModel> cusDetailsList = new List <FollowUpModel>();
                if (model.FollowUpId != null)
                {
                    var cus = db.CustomerFollowUpsGet(null, model.Cid).ToList();


                    foreach (var item in cus)
                    {
                        cusDetailsList.Add(new FollowUpModel()
                        {
                            FollowUpDate     = item.FollowUpDate.Value,
                            FollowUpType     = item.FollowUpType.Value,
                            Comments         = item.Comments,
                            Status           = item.Status.Value,
                            NextFollowUpDate = item.NextFollowUpDate,
                            FollowUpId       = item.FollowUpId,
                            Cid = item.CustomerId.Value
                        });
                    }
                }
                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("FollowUpCustomerDetailsList", model)
                          //,
                          //content1 = RenderRazorViewToString("FollowUpAddForm",fc)
            }
                        ));

            // ModelState.Clear();
        }