Пример #1
0
        public NonIncarceratedStep7 insertStep7(NonIncarceratedStep7 step7, int userid, string Command, out string result, out bool isSuccess)
        {
            try
            {
                Form form = new Form();
                using (BoardofPardonsEntities1 dbcontext = new BoardofPardonsEntities1())
                {
                    form = dbcontext.Forms.Where(a => a.id == step7.FormId).FirstOrDefault();
                    if (Command == "save")
                    {
                        form.Status = 0;
                    }
                    else
                    {
                        form.Status = 1;
                    }

                    var _step7 = dbcontext.NonIncarceratedStep7.Where(a => a.FormId == step7.FormId).FirstOrDefault();
                    if (_step7 == null)
                    {
                        step7.CreatedAt = DateTime.Now;
                        step7           = dbcontext.NonIncarceratedStep7.Add(step7);
                    }
                    else
                    {
                        _step7           = step7;
                        _step7.UpdatedAt = DateTime.Now;
                    }
                    dbcontext.SaveChanges();
                }
                isSuccess = true;
                result    = "Success";
                return(step7);
            }
            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);
            }
        }
 public ActionResult step7(NonIncarceratedStep7 step7, string Command)
 {
     if (Session["formNo"] != null)
     {
         objNonIncarc = new NonInCarceratedManger();
         int mu1 = (int)WebSecurity.CurrentUserId;
         try
         {
             mu1 = Session["UserId"] == null ? WebSecurity.CurrentUserId : (int)Session["UserId"];
         }
         catch (Exception)
         {
         }
         step7.FormId = (int)Session["formNo"];
         step7        = objNonIncarc.insertStep7(step7, mu1, Command, out returnMessage, out isSuccess);
         if (isSuccess)
         {
             if (Command == "save")
             {
                 return(View(step7));
             }
             else if (Command == "submit")
             {
                 sendSubmitEmail();
                 Session["formNo"] = null;
                 return(RedirectToAction("PDFView", "PDFReport", new { id = step7.FormId })); //PDFView(int id)
                 //return RedirectToAction("index", "FormSelect");
             }
             else
             {
                 return(RedirectToAction("step6"));
             }
         }
         else
         {
             return(View(step7));
         }
     }
     else
     {
         return(RedirectToAction("Index", "FormSelect"));
     }
 }
 //step 7
 public ActionResult step7()
 {
     objNonIncarc = new NonInCarceratedManger();
     if (Session["formNo"] == null)
     {
         return(View());
     }
     else
     {
         int formId = (int)Session["formNo"];
         NonIncarceratedStep7 step7 = objNonIncarc.getNonIncarceratedStep7(formId);
         if (step7 != null)
         {
             return(View(step7));
         }
         else
         {
             return(View());
         }
     }
 }