Пример #1
0
        public ActionResult Create(Form form)
        {
            if (ModelState.IsValid)
            {

                List<Models.Attribute> attributes = new List<Models.Attribute>();
                String given_atts = Request["formAttributes"];
                string[] atts = given_atts.Split(',');

                foreach (string little_att in atts)
                {
                    attributes.Add(new Models.Attribute { Name = little_att, Value = little_att });
                }

                form.Attributes = attributes;

                RavenSession.Store(form);
                RavenSession.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(form);
        }
Пример #2
0
        public ActionResult Edit(Form form)
        {
            if (ModelState.IsValid)
            {
                Form form_to_edit = (Form)RavenSession.Query<Form>().Where(f => f.Id == form.Id).First();
                form_to_edit.Name = form.Name;

                // this i am not very certain about...
                // do we just clear the existing list of attributes?
                // or do we loop through the form elements, check to
                // see if one exists, if no, add it -- if it does,
                // check to see if the value is the same -- etc.
                // i think this will look a lot cleaner when i am using
                // ajax to handle individual form element updates instead
                // of the whole shebang.

                List<Models.Attribute> attributes = new List<Models.Attribute>();
                String given_atts = Request["formAttributes"];
                string[] atts = given_atts.Split(',');
                foreach (string little_att in atts)
                {
                    attributes.Add(new Models.Attribute { Name = little_att, Value = little_att });
                }

                form_to_edit.Attributes = attributes;
                RavenSession.SaveChanges();
                return RedirectToAction("Details", form);
            }
            return View(form);
        }