Ejemplo n.º 1
0
        public ActionResult ContatosEmailSave(UserAdressBook model)
        {
            context = new DALContext();

            try
            {
                if (ModelState.IsValid)
                {
                    model.Username = User.Identity.Name;

                    if (model.Id > 0)
                    {
                        context.AddressBooks.Update(model);
                    }
                    else
                    {
                        context.AddressBooks.Create(model);
                    }
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            ViewBag.Message = "Contato cadastrado com sucesso.";

            return(RedirectToAction("ContatosEmailLista"));
        }
Ejemplo n.º 2
0
        public ActionResult ContatosEmailEdit(int?AddressBookID)
        {
            UserAdressBook model = new UserAdressBook();

            model.Username = User.Identity.Name;

            context = new DALContext();

            if (AddressBookID > 0)
            {
                model = context.AddressBooks.Find(p => p.Id == AddressBookID);
            }

            return(View(model));
        }