public async Task <EfCoreGenericRepository.Models.Blog> AddBlog([FromBody] EfCoreGenericRepository.Models.Blog blog)
        {
            await _blogRepository.AddAsyn(blog);

            await _blogRepository.SaveAsync();

            return(blog);
        }
Пример #2
0
 public ActionResult Edit([Bind("BlogId,CreatedBy,CreatedOn,Title,UpdatedBy,UpdatedOn")] EfCoreGenericRepository.Models.Blog blog)
 {
     if (ModelState.IsValid)
     {
         _blogRepository.Update(blog, blog.BlogId);
         return(RedirectToAction("Index"));
     }
     return(View(blog));
 }
Пример #3
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index"));
            }

            EfCoreGenericRepository.Models.Blog blog = _blogRepository.Get((int)id);
            return(View(blog));
        }
Пример #4
0
        public async Task <IActionResult> Create([Bind("Title")] EfCoreGenericRepository.Models.Blog blog)
        {
            if (ModelState.IsValid)
            {
                await _blogRepository.AddAsyn(blog);

                await _blogRepository.SaveAsync();

                return(RedirectToAction("Index"));
            }
            return(View(blog));
        }
Пример #5
0
 public async Task <IActionResult> Delete(int id)
 {
     EfCoreGenericRepository.Models.Blog blog = _blogRepository.Get(id);
     _blogRepository.Delete(blog);
     return(RedirectToAction("Index"));
 }
        //public Blog UpdateBlog([FromBody] Blog blog)
        //{
        //  var updated = _blogRepository.Update(blog, blog.BlogId);
        //  return updated;
        //}
        public async Task <EfCoreGenericRepository.Models.Blog> UpdateBlog([FromBody] EfCoreGenericRepository.Models.Blog blog)
        {
            var updated = await _blogRepository.UpdateAsyn(blog, blog.BlogId);

            return(updated);
        }