コード例 #1
0
        public ActionResult Index()
        {
            var mother = new Mother();
            var childs = new List<Child>();
            //mother.Childs = childs;

            return View(mother);
        }
コード例 #2
0
        // GET: OrgUploader
        public ActionResult Index()
        {
            var mother = new Mother();
            TempData["mother"] = null;
            if (TempData["mother"] != null)
            {
                mother = TempData["mother"] as Mother;

            }

            return View(mother);
        }
コード例 #3
0
        public ActionResult Index(Mother mother, string childname, HttpPostedFileBase file)
        {
            var child = new Child();
            child.ChildName = childname;

            if (file!= null)
            {
                child.fileName = file.FileName;
                child.file = file;
                //child.fileStream = file.InputStream;
            }

            mother.Childs.Add(child);

            return View(mother);
        }
コード例 #4
0
        public ActionResult Index(Mother m, HttpPostedFileBase file_nomodel, string childname)
        {
            // Init model
            var mother = new Mother();

            // Get saved Model from previous, As File type can only save in Session, and lost if communicated with view and Controller
            if (TempData["mother"] != null)
            {
                mother = TempData["mother"] as Mother;
            }

            if (Request.Files.Count > 0)
            {
                for (int i = 0; i < Request.Files.Count; i++ )
                {
                    var child = new Child();
                    child.ChildName = childname;
                    child.fileName = Request.Files[i].FileName;
                    child.file = Request.Files[i];
                    mother.Childs.Add(child);
                }
            }

            //if (file_nomodel != null)
            //{
            //    var child = new Child();
            //    child.ChildName = childname;
            //    child.fileName = file_nomodel.FileName;
            //    child.file = file_nomodel;
            //    mother.Childs.Add(child);
            //}
            mother.MotherName = m.MotherName;
            TempData["mother"] = mother;

            return View(mother);
        }