public async Task<IHttpActionResult> PutReport(int id, Report report) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != report.Id) { return BadRequest(); } db.Entry(report).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ReportExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostReport(Report report) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Reports.Add(report); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = report.Id }, report); }
public async Task<ActionResult> Index (Report model) { if(ModelState.IsValid){ db.Reports.Add(model); await db.SaveChangesAsync(); } ViewBag.CenterId = new SelectList( db.Centers, "Id", "Name" ); ViewBag.HarmonicGroupId = new SelectList( db.HarmonicGroups, "Id", "Name" ); ViewBag.SocialStyleId = new SelectList( db.SocialStyles, "Id", "Name" ); ViewBag.TonalityId = new SelectList( db.Tonalities, "Id", "Name" ); return View(model); }