public async Task<IHttpActionResult> Post(Namespace ns, [ValueProvider(typeof(CultureValueProviderFactory))] string culture = "en-US") { if (!ModelState.IsValid) { return BadRequest(ModelState); } var dictionary = new Dictionary {Id = ns.Id, Description = ns.Description}; db.Dictionaries.Add(dictionary); await db.SaveChangesAsync(); return Created(ns); }
public async Task<IHttpActionResult> Put([FromODataUri] string key, Namespace ns, [ValueProvider(typeof(CultureValueProviderFactory))] string culture = "en-US") { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (key != ns.Id) { return BadRequest(); } var dictionary = new Dictionary {Id = ns.Id, Description = ns.Description}; db.Entry(dictionary).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!NamespaceExists(key)) { return NotFound(); } else { throw; } } return Updated(ns); }