public async Task <IHttpActionResult> PutAnotherModel(int id, AnotherModel anotherModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != anotherModel.Id) { return(BadRequest()); } db.Entry(anotherModel).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AnotherModelExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
static void Test() { var model = new ProjectValue(); var model2 = new AnotherModel(); var viewModel = model2.HydrateEntityToVM(); var viewModel2 = model2.HydrateEntityToVM(); }
public IActionResult Create(CustomModel model, AnotherModel anotherModel) { this.data.Models.Add(model); this.anotherData.OtherModels.Add(anotherModel); return(this.Ok()); }
public void CreateAnother(AnotherModel another) { if (another == null) { throw new ArgumentNullException(nameof(another)); } _anotherContext.AnotherModels.Add(another); }
public async Task <IHttpActionResult> GetAnotherModel(int id) { AnotherModel anotherModel = await db.AnotherModels.FindAsync(id); if (anotherModel == null) { return(NotFound()); } return(Ok(anotherModel)); }
// // GET: /EditorExample/ public ActionResult Index() { AnotherModel model = new AnotherModel(); model.InnerProp1 = new InnerModel { Input = "test 1" }; model.InnerProp2 = new InnerModel { Input = "test 2" }; return(View(model)); }
public async Task <IHttpActionResult> PostAnotherModel(AnotherModel anotherModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.AnotherModels.Add(anotherModel); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = anotherModel.Id }, anotherModel)); }
public async Task <IHttpActionResult> DeleteAnotherModel(int id) { AnotherModel anotherModel = await db.AnotherModels.FindAsync(id); if (anotherModel == null) { return(NotFound()); } db.AnotherModels.Remove(anotherModel); await db.SaveChangesAsync(); return(Ok(anotherModel)); }
public void UpdateAnother(AnotherModel another) { // _anotherContext.AnotherModels.Add(another); // this instruction is not necessary it seems }