Exemple #1
0
 public ActionResult EditChapterAlias(AliasChapterRel aliaschapterrel)
 {
     if (ModelState.IsValid)
     {
         _aliaschapterrelRepository.InsertOrUpdate(aliaschapterrel);
         _aliaschapterrelRepository.Save();
         return(RedirectToAction("Details", "Chapters", new { id = aliaschapterrel.ChapterId }));
     }
     return(View(aliaschapterrel));
 }
Exemple #2
0
 public void InsertOrUpdate(AliasChapterRel aliaschapterrel)
 {
     if (aliaschapterrel.Id == default(int))
     {
         // New entity
         context.AliasChapterRels.Add(aliaschapterrel);
     }
     else
     {
         // Existing entity
         context.Entry(aliaschapterrel.Alias).State = EntityState.Modified;
         context.Entry(aliaschapterrel).State       = EntityState.Modified;
     }
 }
Exemple #3
0
        //
        // GET: /AliasPersonRels/Create
        public ActionResult CreateChapterAlias(int chapterId)
        {
            ViewBag.ChapterId = chapterId;
            var alias = new AliasChapterRel
            {
                ChapterId = chapterId,
                Alias     = new Alias()
            };

            if (Request.IsAjaxRequest())
            {
                return(PartialView("_CreateOrEditChapterAlias", alias));
            }
            return(View(alias));
        }
Exemple #4
0
        public ActionResult CreateChapterAlias(AliasChapterRel aliaschapterrel)
        {
            //if (aliaschapterrel.FirstKnownUseDate > aliaschapterrel.LastKnownUseDate)
            //   this.ModelState.AddModelError("FirstKnownUseDate", "First Known Use Date is greater than Last Known Use Date.");
            try
            {
                if (ModelState.IsValid)
                {
                    _aliaschapterrelRepository.InsertOrUpdate(aliaschapterrel);
                    _aliaschapterrelRepository.Save();
                    return(RedirectToAction("Details", "Chapters", new { id = aliaschapterrel.ChapterId }));
                }
            }
            catch (Exception ex)
            {
                // Log the exception somewhere to be looked at later
                ModelState.AddModelError("*", "An unexpected error occurred.");
            }

            return(View(aliaschapterrel));
        }