Exemplo n.º 1
0
        public ActionResult Edit([Bind(Include = "Id,PersonId,OrganizationId,Id,ContactType,ContactDetails")] ContactViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (!UserCanEdit(model.PersonId, model.OrganizationId))
                {
                    return(HttpNotFound());
                }

                var contact = model.MapToContact();
                Database.Entry(contact).State = EntityState.Modified;
                Database.SaveChanges();

                return(ReturnToSender(model.PersonId, model.OrganizationId));
            }

            ViewBag.ContactTypes = ContactHelper.GetContactTypes();
            return(PartialView(model));
        }
Exemplo n.º 2
0
        public ActionResult Create([Bind(Include = "PersonId,OrganizationId,Id,ContactType,ContactDetails")] ContactViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (!UserCanEdit(model.PersonId, model.OrganizationId))
                {
                    return(HttpNotFound());
                }

                var contact = model.MapToContact();
                Database.Contacts.Add(contact);
                Database.SaveChanges();

                return(ReturnToSender(model.PersonId, model.OrganizationId));
            }

            ViewBag.ContactTypes = ContactHelper.GetContactTypes();
            return(View(model));
        }