Esempio n. 1
0
        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());
        }
Esempio n. 2
0
        public ActionResult DeleteConfirmed(long id)
        {
            MyPortfolio myPortfolio = db.MyPortfolios.Find(id);

            db.MyPortfolios.Remove(myPortfolio);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 3
0
        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));
        }
Esempio n. 4
0
 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));
 }
Esempio n. 5
0
        // 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));
        }