Example #1
0
 public ActionResult EditPersonAlias(AliasPersonRel aliaspersonrel)
 {
     ViewBag.CommonPersonId = aliaspersonrel.PersonId;
     if (ModelState.IsValid)
     {
         _aliaspersonrelRepository.InsertOrUpdate(aliaspersonrel);
         _aliaspersonrelRepository.Save();
         //TODO:  Make sure this is the right PersonId to return
         //                return RedirectToAction("Details", "Persons", new { id = aliaspersonrel.PersonId });
     }
     return(View(aliaspersonrel));
 }
Example #2
0
 public void InsertOrUpdate(AliasPersonRel aliaspersonrel)
 {
     if (aliaspersonrel.Id == default(int))
     {
         // New entity
         context.Aliases.Add(aliaspersonrel.Alias);
         context.AliasPersonRels.Add(aliaspersonrel);
     }
     else
     {
         // Existing entity
         context.Entry(aliaspersonrel.Alias).State = EntityState.Modified;
         context.Entry(aliaspersonrel).State       = EntityState.Modified;
     }
 }
Example #3
0
        //
        // GET: /AliasPersonRels/Create
        public ActionResult CreatePersonAlias(int personId)
        {
            //            var person = _personRepo.Get(personId, currentUser);
            //            ViewBag.CommonPersonId = personId;

            var alias = new AliasPersonRel
            {
                PersonId = personId,
                Alias    = new Alias()
            };

            if (Request.IsAjaxRequest())
            {
                return(PartialView("_CreateOrEditPersonAlias", alias));
            }
            return(View(alias));
        }
Example #4
0
        public ActionResult CreatePersonAlias(AliasPersonRel aliaspersonrel)
        {
            try
            {
                ViewBag.CommonPersonId = aliaspersonrel.PersonId;
                if (ModelState.IsValid)
                {
                    _aliaspersonrelRepository.InsertOrUpdate(aliaspersonrel);
                    _aliaspersonrelRepository.Save();
                    //TODO:  Make sure this is the right PersonId to return
                    //                    return RedirectToAction("Details", "Persons", new { id = aliaspersonrel.PersonId });
                }
            }
            catch (Exception ex)
            {
                var s = ex.Message;
                // Log the exception somewhere to be looked at later
                ModelState.AddModelError("*", "An unexpected error occurred.");
            }


            return(View(aliaspersonrel));
        }