public async Task <IActionResult> PutMyPortfolio([FromRoute] int id, [FromBody] MyPortfolio myPortfolio) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != myPortfolio.Id) { return(BadRequest()); } _context.Entry(myPortfolio).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MyPortfolioExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult DeleteConfirmed(long id) { MyPortfolio myPortfolio = db.MyPortfolios.Find(id); db.MyPortfolios.Remove(myPortfolio); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <IActionResult> PostMyPortfolio([FromBody] MyPortfolio myPortfolio) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.MyPortfolios.Add(myPortfolio); await _context.SaveChangesAsync(); return(CreatedAtAction("GetMyPortfolio", new { id = myPortfolio.Id }, myPortfolio)); }
public ActionResult Edit([Bind(Include = "Id,Name,Description,DisplayOrder,LastModifiedDate")] MyPortfolio myPortfolio) { myPortfolio.LastModifiedDate = DateTime.Now; myPortfolio.ProfileId = new Guid(User.Identity.GetUserId()); if (ModelState.IsValid) { db.Entry(myPortfolio).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(myPortfolio)); }
// GET: MyPortfolios/Edit/5 public ActionResult Edit(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } MyPortfolio myPortfolio = db.MyPortfolios.Find(id); if (myPortfolio == null) { return(HttpNotFound()); } return(View(myPortfolio)); }