public ActionResult Edit(QuesitonAndAnswerEditModel model)
 {
     if (ModelState.IsValid)
     {
         var entity = AutoMapper.Mapper.Map <Entities.KnowledgeBaseItem>(model);
         try
         {
             KnowledgeData.Edit(entity);
             return(new RedirectToRouteResult(new System.Web.Routing.RouteValueDictionary(new { action = "Index", controller = "HomeController" })));
         }
         catch (Exception)
         {
             ModelState.AddModelError("Concurrency", "Another user might have modified the same record you are trying to make updates. Please refresh and try again.");
         }
     }
     return(View(model));
 }
Example #2
0
 public ActionResult Edit(QuesitonAndAnswerEditModel model)
 {
     if (ModelState.IsValid)
     {
         var entity = AutoMapper.Mapper.Map <Entities.KnowledgeBaseItem>(model);
         try
         {
             //TODO: Implement this part of code to persist changes into database.
             throw new NotImplementedException();
         }
         catch (Exception)
         {
             ModelState.AddModelError("Concurrency", "Another user might have modified the same record you are trying to make updates. Please refresh and try again.");
         }
     }
     return(View(model));
 }
        // GET: Question
        public ActionResult Edit(int id)
        {
            Entities.KnowledgeBaseItem toEdit = KnowledgeQuery.Get(id);

            if (toEdit == null)
            {
                return(new RedirectResult("~/Shared/Error"));
            }

            QuesitonAndAnswerEditModel model = new QuesitonAndAnswerEditModel
            {
                Answer     = toEdit.Answer,
                Id         = toEdit.Id,
                Question   = toEdit.Query,
                RowVersion = toEdit.RowVersion,
                Tags       = toEdit.Tags,
            };

            return(View(model));
        }