Ejemplo n.º 1
0
        public ActionResult NewsAdd(NewsModel model, HttpPostedFileBase Photo)
        {
            if (Photo != null)
            {
                var fileName = Path.GetFileNameWithoutExtension(Photo.FileName);
                var extension = Path.GetExtension(Photo.FileName);
                var fileFullName = Guid.NewGuid() + fileName.Replace(" ", "").Replace(".", "") + extension;
                var path = Path.Combine(Server.MapPath("~/Content/images/haber"), fileFullName);
                Photo.SaveAs(path);

                News news = new News
                {
                    Active = model.Active,
                    Content = model.Content,
                    Photo = "images/haber/" + fileFullName,
                    Creator = model.Creator,
                    Date = model.Date,
                    Title = model.Title,
                    SeoUrl = Change(model.Title)
                };

                _newsService.Insert(news);
                _uow.SaveChanges();
            }

            return RedirectToAction("ListNews");
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Delete a news by news entity.
 /// </summary>
 /// <param name="news">News</param>
 public void Delete(News news)
 {
     _newsRepository.Delete(news);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Update a news.
 /// </summary>
 /// <param name="news"></param>
 public void Update(News news)
 {
     _newsRepository.Update(news);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Insert new news.
 /// </summary>
 /// <param name="news"></param>
 public void Insert(News news)
 {
     _newsRepository.Insert(news);
 }