public IncarceratedStep1 insertStep1(IncarceratedStep1 step1, int userid, string Command, out string result, out bool isSuccess)
        {
            try
            {
                Form form = new Form();
                using (BoardofPardonsEntities1 dbcontext = new BoardofPardonsEntities1())
                {
                    form.CreatedAt = DateTime.Now;
                    form.UserId    = userid;
                    form.Type      = 2;
                    if (Command == "save")
                    {
                        form.Status = 0;
                    }
                    else
                    {
                        form.Status = 1;
                    }

                    form = dbcontext.Forms.Add(form);
                    dbcontext.SaveChanges();
                    step1.CreatedAt = DateTime.Now;

                    step1.FormId = form.id;
                    step1        = dbcontext.IncarceratedStep1.Add(step1);
                    dbcontext.SaveChanges();
                }
                isSuccess = true;
                result    = "Success";
                return(step1);
            }
            catch (Exception ex)
            {
                using (StreamWriter writer =
                           new StreamWriter(HostingEnvironment.MapPath("~/errLog.txt")))
                {
                    writer.WriteLine("==========================");
                    writer.WriteLine("Date " + DateTime.Now);
                    writer.WriteLine("Error" + ex.Message);
                }
                isSuccess = false;
                result    = ex.Message;
                return(null);
            }
        }
 //step 1
 public ActionResult step1()
 {
     objIncarc = new InCarceratedManger();
     if (Session["formNo"] == null)
     {
         return(View());
     }
     else
     {
         int formId = (int)Session["formNo"];
         IncarceratedStep1 step1 = objIncarc.getIncarceratedStep1(formId);
         if (step1 != null)
         {
             return(View(step1));
         }
         else
         {
             return(View());
         }
     }
 }
 public ActionResult step1(IncarceratedStep1 step1, string Command)
 {
     if (Session["formNo"] == null)
     {
         objIncarc = new InCarceratedManger();
         int mu1 = (int)WebSecurity.CurrentUserId;
         try
         {
             mu1 = Session["UserId"] == null ? WebSecurity.CurrentUserId : (int)Session["UserId"];
         }
         catch (Exception)
         {
         }
         step1 = objIncarc.insertStep1(step1, mu1, Command, out returnMessage, out isSuccess);
         if (isSuccess)
         {
             Session["formNo"] = step1.FormId;
             if (Command == "save")
             {
                 return(RedirectToAction("step2"));
             }
             else
             {
                 sendSubmitEmail();
                 return(RedirectToAction("PDFView", "PDFReport", new { id = step1.FormId })); //PDFView(int id)
                 //return RedirectToAction("index", "FormSelect");
             }
         }
         else
         {
             return(View(step1));
         }
     }
     else
     {
         Session["formNo"] = null;
         return(RedirectToAction("Index", "FormSelect"));
     }
 }