Exemplo n.º 1
0
        public DataResponse Add(Blog entity)
        {
            var blog = _blogDal.Add(entity);

            if (blog == null)
            {
                return new DataResponse
                       {
                           Mesaj      = "Blog Eklenemedi",
                           Tamamlandi = false,
                       }
            }
            ;
            return(new DataResponse
            {
                Data = blog,
                Tamamlandi = true,
                Mesaj = blog.Baslik + " Baslikli Blog Eklendi",
            });
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create(Blog blog, IFormFile file)
        {
            if (file?.Length > 5000000)
            {
                ModelState.AddModelError(ConstStrings.FileSize, ConstStrings.FileLimit);
            }

            if (file != null && !file.ContentType.Contains(ConstStrings.Image))
            {
                ModelState.AddModelError(ConstStrings.WrongType, ConstStrings.ImageError);
            }

            if (ModelState.IsValid)
            {
                if (file != null)
                {
                    await UploadImage(blog, file);
                }
                else
                {
                    blog.Image      = "dummy.jpg";
                    blog.ImageThumb = "dummy_thumb.jpg";
                }

                if (string.IsNullOrWhiteSpace(blog.Body))
                {
                    blog.Body = ConstStrings.NonBodyInArticle;
                }

                blog.Date = DateTime.Now;
                _blogDal.Add(blog);
                return(RedirectToAction("List", "Blogs"));
            }
            ViewBag.Categories = new SelectList(_categoryDal.GetList(), "Id", "Name");
            return(View(blog));
        }
Exemplo n.º 3
0
 public void Add(Blog blog)
 {
     _blogDal.Add(blog);
 }
Exemplo n.º 4
0
 public void Add(Blog entity)
 {
     _blogDal.Add(entity);
 }
Exemplo n.º 5
0
 public Blog Add(Blog blog)
 {
     return(_blogDal.Add(blog));
 }
Exemplo n.º 6
0
 public IResult Add(Blog entity)
 {
     _blogDal.Add(entity);
     return(new SuccessResult());
 }