[HttpPost] //create public string Post([FromBody] Localidades value) { string response = "Se ha guardado Correctamente"; Localidades Entity = new Localidades(); Entity.Nombre = value.Nombre; Entity.CodPostal = value.CodPostal; Entity.IdProvincia = value.IdProvincia; try { _db.Localidades.Add(Entity); _db.SaveChanges(); } catch (Exception ex) { response = "Una Wea mala ha ocurrido"; throw ex; } return(response); }
public JsonResult Put([FromBody] Heroes hero) { try { Heroes Entity = _db.Heroes.Where(x => x.Id == hero.Id).FirstOrDefault(); if (Entity == null) { return(Json(HttpStatusCode.NotFound)); } Entity.Name = hero.Name; Entity.Alias = hero.Alias; Entity.Quirk = hero.Quirk; _db.SaveChanges(); return(Json(HttpStatusCode.OK)); } catch (Exception) { return(Json(HttpStatusCode.NotModified)); throw; } }