示例#1
0
        public ActionResult CreateAuto(Walk walk)
        {
            // ----This should really be done by a customised Model Binder-----------
            Walk oWalk = new Walk();

            WalkingStick.FillWalkFromFormVariables(ref oWalk, Request.Form);
            int iWalkID = this.repository.AddWalk(oWalk);

            // ---Add hill ascents-----------------
            List <HillAscent> arHillAscents = WalkingStick.FillHillAscentsFromFormVariables(iWalkID, this.Request.Form);

            repository.AddWalkSummitsVisited(arHillAscents);

            // ---Add the associated files-----
            // --TODO - this needs to change to pull files from disk rather than form variable
            List <Walk_AssociatedFile> arWalkAssociatedFiles = WalkingStick.FillWalkAssociatedFilesByExaminingDirectory(
                iWalkID,
                this.Request.Form,
                this.Server.MapPath("~/Content/images/").Replace("\\", "/"));

            repository.AddWalkAssociatedFiles(arWalkAssociatedFiles);

            //---Redirect to the newly created walk to continue editing
            return(RedirectToAction("Edit", new { id = iWalkID }));
        }
示例#2
0
        public ActionResult Create(Walk walk)
        {
            // ----This should really be done by a customised Model Binder-----------
            Walk oWalk = new Walk();

            WalkingStick.FillWalkFromFormVariables(ref oWalk, Request.Form);
            int iWalkID = this.repository.AddWalk(oWalk);

            // ---Add hill ascents-----------------
            List <HillAscent> arHillAscents = WalkingStick.FillHillAscentsFromFormVariables(iWalkID, this.Request.Form);

            repository.AddWalkSummitsVisited(arHillAscents);

            // ---Add the associated files-----
            List <Walk_AssociatedFile> arAssociatedFiles = WalkingStick.FillHillAssociatedFilesFromFormVariables(
                iWalkID,
                this.Request.Form,
                this.Server.MapPath("/"));

            repository.AddWalkAssociatedFiles(arAssociatedFiles);

            // ---update any markers created by ajax call with walk id, and add any marker observations----------------
            repository.AssociateMarkersWithWalk(Request.Form, iWalkID);
            if ((walk.HillAscents.Count > 0))
            {
                return(RedirectToAction("HillsByArea", new { id = oWalk.Area.Arearef.Trim(), page = 1 }));
            }

            return(RedirectToAction("WalksByDate", new { OrderBy = "DateDesc" }));
        }