Exemplo n.º 1
0
        public async Task <IActionResult> PutComment(int id, Comment comment)
        {
            if (id != comment.Id)
            {
                return(BadRequest());
            }

            _context.Entry(comment).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CommentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(CreatedAtAction("GetComment", new { id = comment.Id }, comment));
        }
Exemplo n.º 2
0
        public IActionResult GetById(int id)
        {
            var comment = _context.Comments.Find(id);

            _context.Entry(comment).Collection(comment => comment.Replies).Load();

            if (comment == null)
            {
                return(StatusCode(StatusCodes.Status404NotFound));
            }

            return(StatusCode(StatusCodes.Status200OK, new JsonResult(comment)));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> PutTopic(long id, Topic topic)
        {
            if (id != topic.Id)
            {
                return(BadRequest());
            }

            _context.Entry(topic).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TopicExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public ActionResult Edit(Comment comment)
        {
            if (ModelState.IsValid)
            {
                Hitchhiker h1 = hdb.Hitchhikers.Where(h => h.Name == comment.Author).SingleOrDefault();

                if (comment.Hitchhiker == false)
                {
                    if (h1 != null)
                    {
                        hdb.Hitchhikers.RemoveRange(hdb.Hitchhikers.Where(c => c.PostID == h1.PostID));
                    }
                }
                else
                {
                    if (h1 != null)
                    {
                        h1.Phone            = comment.PhoneNumber;
                        hdb.Entry(h1).State = EntityState.Modified;
                    }
                    else
                    {
                        h1 = new Hitchhiker()
                        {
                            Name = comment.Author, Phone = comment.PhoneNumber, PostID = comment.RefferedPost
                        };
                        hdb.Hitchhikers.Add(h1);
                    }
                }
                hdb.SaveChanges();
                cdb.Entry(comment).State = EntityState.Modified;
                cdb.SaveChanges();
                return(RedirectToAction("Index", "Users"));
            }
            return(RedirectToAction("Index", "Users"));
        }
Exemplo n.º 5
0
 public void Update(Note nts)
 {
     db.Entry(nts).State = EntityState.Modified;
 }
 public void Update(Correction cors)
 {
     db.Entry(cors).State = EntityState.Modified;
 }
Exemplo n.º 7
0
 public void Update(TakeOff tf)
 {
     db.Entry(tf).State = EntityState.Modified;
 }
Exemplo n.º 8
0
 public void Update(RequestForSpecification rqsp)
 {
     db.Entry(rqsp).State = EntityState.Modified;
 }
Exemplo n.º 9
0
 public void Update(AnswerToRequestToTakeOff anrqtkof)
 {
     db.Entry(anrqtkof).State = EntityState.Modified;
 }
Exemplo n.º 10
0
 public void Update(RequestForTakeOff rqtf)
 {
     db.Entry(rqtf).State = EntityState.Modified;
 }
 public void Update(CorrectionStatus crst)
 {
     db.Entry(crst).State = EntityState.Modified;
 }
Exemplo n.º 12
0
 public void Update(RequestForCorrection rqcr)
 {
     db.Entry(rqcr).State = EntityState.Modified;
 }
Exemplo n.º 13
0
 public void Update(Specification sps)
 {
     db.Entry(sps).State = EntityState.Modified;
 }
Exemplo n.º 14
0
 public void Update(NoteStatus ntst)
 {
     db.Entry(ntst).State = EntityState.Modified;
 }
 public void Update(RequestForUpdateStatus rqup)
 {
     db.Entry(rqup).State = EntityState.Modified;
 }
Exemplo n.º 16
0
 public void Update(Additional addnls)
 {
     db.Entry(addnls).State = EntityState.Modified;
 }
 public void Update(AnswerToRequestSpecification anrqsp)
 {
     db.Entry(anrqsp).State = EntityState.Modified;
 }
Exemplo n.º 18
0
 public void Update(TakeOffStatus tfst)
 {
     db.Entry(tfst).State = EntityState.Modified;
 }