Exemplo n.º 1
0
        public ActionResult AddCaseStudy(int?id)
        {
            cf = new common_function();
            ViewData["ServiceList"] = cf.GetServiceType();
            var Get = m_db.case_details.Where(a => a.id == id).Where(a => a.m_status_id == 1).FirstOrDefault();

            if (Get != null)
            {
                return(View(Get));
            }
            return(View());
        }
Exemplo n.º 2
0
        public ActionResult AddCaseStudy(case_details caseD, HttpPostedFileBase image, HttpPostedFileBase white_paper)
        {
            if (ModelState.IsValid)
            {
                var image_name = "";
                if (image != null)
                {
                    if ((image.ContentLength > 0))
                    {
                        image_name = "img_" + DateTime.Now.ToString("ddMMyyyyhhmmss") + Path.GetExtension(image.FileName);
                        string path = Path.Combine(Server.MapPath("~/Case-Images"), image_name);
                        image.SaveAs(path);
                    }
                    caseD.image = image_name;
                }
                else if (caseD.image != "" && caseD.image != null)
                {
                    image_name = caseD.image;
                }
                else
                {
                    cf = new common_function();
                    ViewData["ServiceList"] = cf.GetServiceType();
                    ModelState.AddModelError("", "Choose image");
                    return(View(caseD));
                }
                var wp_name = "";
                if (white_paper != null)
                {
                    if ((white_paper.ContentLength > 0))
                    {
                        wp_name = "wp_" + DateTime.Now.ToString("ddMMyyyyhhmmss") + Path.GetExtension(white_paper.FileName);
                        string path = Path.Combine(Server.MapPath("~/White-Papers"), wp_name);
                        white_paper.SaveAs(path);
                    }
                    caseD.white_paper = wp_name;
                }
                else if (caseD.white_paper != "" && caseD.white_paper != null)
                {
                    wp_name = caseD.white_paper;
                }
                else
                {
                    cf = new common_function();
                    ViewData["ServiceList"] = cf.GetServiceType();
                    ModelState.AddModelError("", "Choose white paper");
                    return(View(caseD));
                }

                var Get = m_db.case_details.Where(a => a.id == caseD.id).FirstOrDefault();
                if (Get != null)
                {
                }
                else
                {
                    caseD.date_of_creation = DateTime.Now;
                    caseD.m_status_id      = 1;
                    m_db.case_details.Add(caseD);
                    m_db.SaveChanges();
                }
                return(RedirectToAction("AddCaseStudy/0", "Admin"));
            }
            else
            {
                cf = new common_function();
                ViewData["ServiceList"] = cf.GetServiceType();
                return(View(caseD));
            }
        }