Example #1
0
        public SurveyFull AddSurvey(SurveyAdd newItem)
        {
            // Calculate the next value for the identifier
            int newId = (surveys.Count > 0) ? newId = surveys.Max(id => id.Id) + 1 : 1;

            Survey addedItem = Mapper.Map <Survey>(newItem);

            addedItem.Id = newId;

            // Add the new item to the store
            surveys.Add(addedItem);

            // Return the new item
            return(Mapper.Map <SurveyFull>(addedItem));
        }
        public ActionResult Create(SurveyAdd newItem)
        {
            SurveyFull addedItem = null;

            // Check that the incoming data is valid
            if (ModelState.IsValid)
            {
                addedItem = m.AddSurvey(newItem);
            }
            else
            {
                // Return the object so the user can edit it correctly
                return(View(newItem));
            }

            return(RedirectToAction("index"));
        }
Example #3
0
        //adding method
        public SurveyFull AddSurvey(SurveyAdd newItem)
        {
            //New id
            int newId = (surveys.Count > 0) ? newId = surveys.Max(id => id.Id) + 1 : 1;

            //new item w/ Mapper
            Survey addedItem;

            addedItem    = Mapper.Map <Survey>(newItem);
            addedItem.Id = newId;

            //Add new item
            surveys.Add(addedItem);

            //return value
            return(Mapper.Map <SurveyFull>(addedItem));
        }