Esempio n. 1
0
        public ActionResult Create([Bind(Include = "Id,PersonId,PhoneNumber,PhoneTypeId")] Phone phone)
        {
            if (ModelState.IsValid)
            {
                _phoneService.AddOrUpdate(phone);
                string url = Url.Action("ListPhones", "Phones", new { Id = phone.PersonId });
                return(Json(new { success = true, url = url, target = "#idPhone" }));
            }

            ViewBag.PhoneTypeId = new SelectList(_genericService.GetAll <PhoneType>(), "Id", "Label", phone.PhoneTypeId);
            return(PartialView("_Create", phone));
        }
Esempio n. 2
0
        public IHttpActionResult PutPhone(int id, Phone phone)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            if (!PhoneExists(id))
            {
                return(NotFound());
            }
            else
            {
                _phoneService.AddOrUpdate(phone);
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }