Esempio n. 1
0
        public async Task <IActionResult> Create([Bind("ID,Name,Diet,NeedToKnow,Behavior,SocialInteraction,PackLimits,Image,Additionalinfo")] Dinosaur dinosaur)
        {
            if (ModelState.IsValid)
            {
                _context.Add(dinosaur);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(dinosaur));
        }
Esempio n. 2
0
        public async Task <IActionResult> Create([Bind("ID,Title,BloggerName,Posts,User")] Models.Blog blog)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(blog);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 3
0
        public async Task <IActionResult> Delete(int id)
        {
            var D = await _db.Dino.FirstOrDefaultAsync(u => u.Id == id);

            if (D != null)
            {
                _db.Dino.Remove(D);
                await _db.SaveChangesAsync();

                return(Json(new { success = true, message = "Delete successful" }));
            }
            return(Json(new { success = false, message = "Error while Deleting" }));
        }
Esempio n. 4
0
        public async Task <IActionResult> OnPostDelete(int id)
        {
            var D = await _db.Dino.FindAsync(id);

            if (D != null)
            {
                _db.Dino.Remove(D);
                await _db.SaveChangesAsync();

                return(RedirectToPage("Index"));
            }
            return(NotFound());
        }
Esempio n. 5
0
        public async Task<IActionResult> OnPost()
        {
            if (ModelState.IsValid)
            {
                await _db.Dino.AddAsync(Dino);
                await _db.SaveChangesAsync();
                return RedirectToPage("Index");
            }
            else
            {
                return RedirectToPage("Create");
            }

        }
Esempio n. 6
0
        public async Task <IActionResult> OnPost(int id)
        {
            if (ModelState.IsValid)
            {
                var D = await _db.Dino.FindAsync(id);

                D.Name   = Dino.Name;
                D.Period = Dino.Period;
                D.Diet   = Dino.Diet;
                await _db.SaveChangesAsync();

                return(RedirectToPage("Index"));
            }
            else
            {
                return(RedirectToPage("Edit"));
            }
        }
Esempio n. 7
0
 public async Task CreateDinosaur(Dinosaur dinosaur)
 {
     _context.Add(dinosaur);
     await _context.SaveChangesAsync();
 }
Esempio n. 8
0
 public async Task CreatePost(Post post)
 {
     _context.Add(post);
     await _context.SaveChangesAsync();
 }
Esempio n. 9
0
 public async Task CreateBlog(Blog blog)
 {
     _context.Add(blog);
     await _context.SaveChangesAsync();
 }