Ejemplo n.º 1
0
        public ActionResult SaveGlossary(FormCollection collection)
        {
            var model = new GlossaryView();

            try
            {
                if (TryUpdateModel(model))
                {
                    var glossaryDto = model.ToGlossaryDto();
                    if (glossaryDto == null)
                    {
                        return(Json(new { success = false, errorMessage = "Error saving glossary" }));
                    }

                    // new glossary
                    if (model.Id == -1)
                    {
                        _glossaryBusinessManager.AddGlossary(glossaryDto);
                    }
                    else//edit existing glossary
                    {
                        _glossaryBusinessManager.UpdateGlossary(glossaryDto);
                    }

                    var glossaryModel = GetGlossaryModel();
                    return(Json(new { success = true, model = MvcHelper.EncodeJson(glossaryModel) }, JsonRequestBehavior.AllowGet));
                }
                return(Json(new { success = false, errorMessage = string.Join(Environment.NewLine, ModelState.GetErros().ToArray()) }));
            }
            catch
            {
                return(Json(new { success = false, errorMessage = "Error saving glossary" }));
            }
        }
Ejemplo n.º 2
0
 public static Glossary ToGlossaryDto(this GlossaryView glossary)
 {
     try
     {
         return(new Glossary()
         {
             GlossaryId = glossary.Id, Term = glossary.Term, Definition = glossary.Definition
         });
     }
     catch (Exception)
     {
         return(null);
     }
 }
Ejemplo n.º 3
0
        public ActionResult Term(int?id, string term)
        {
            var m = new GlossaryView();

            //m.Terms = DataAccess.GetAllTerms();
            if (id.HasValue)
            {
                m.ActiveTerm = DataAccess.GetSingleTerm(id.Value);
            }
            else if (!string.IsNullOrEmpty(term))
            {
                m.ActiveTerm = DataAccess.GetSingleTerm(term);
            }

            m.Version = DataAccess.GetKeyValue("GlossaryVersion");

            return(View("Term", m));
        }
Ejemplo n.º 4
0
        public ActionResult Term(int? id, string term)
        {
            var m = new GlossaryView();

            //m.Terms = DataAccess.GetAllTerms();
            if (id.HasValue)
            {
                m.ActiveTerm = DataAccess.GetSingleTerm(id.Value);
            }
            else if (!string.IsNullOrEmpty(term))
            {
                m.ActiveTerm = DataAccess.GetSingleTerm(term);
            }

            m.Version = DataAccess.GetKeyValue("GlossaryVersion");

            return View("Term",m);
        }