public IHttpActionResult PutEmail(int id, Email email)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != email.Id)
            {
                return(BadRequest());
            }


            if (!EmailExists(id))
            {
                return(NotFound());
            }
            else
            {
                _emailService.AddOrUpdate(email);
            }


            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #2
0
        public ActionResult Create([Bind(Include = "Id,PersonId,EmailAddress,EmailTypeId")] Email email)
        {
            if (ModelState.IsValid)
            {
                _emailService.AddOrUpdate(email);
                string url = Url.Action("ListEmails", "Emails", new { Id = email.PersonId });
                return(Json(new { success = true, url = url, target = "#idEmail" }));
            }

            ViewBag.EmailTypeId = new SelectList(_genericService.GetAll <EmailType>(), "Id", "Label", email.EmailTypeId);
            return(PartialView("_Create", email));
        }