Exemplo n.º 1
0
 public static Seo ToDB(this BllSeo entity)
 {
     return(new Seo
     {
         Id = entity.Id,
         Name = entity.Name
     });
 }
Exemplo n.º 2
0
 public static BllPage ToBll(this PageViewModel entity, BllSeo seo)
 {
     return(new BllPage
     {
         Id = entity.Id,
         Content = entity.Page,
         CategoryId = entity.CategoryId,
         Title = entity.Title,
         UrlId = seo.Id,
         CreationDate = DateTime.Now
     });
 }
Exemplo n.º 3
0
        public ActionResult AddPage(PageViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(this.View(model));
            }

            var result = _pagesService.Get(model.Id);

            if (result != null)
            {
                var seoEquals = _seoService.Get(model.Id)?.Name.Equals(model.SeoUrl);

                var seoUrl = new BllSeo
                {
                    Id   = model.Id,
                    Name = model.SeoUrl
                };

                if (seoEquals.HasValue && !seoEquals.Value)
                {
                    _seoService.Update(new BllSeo
                    {
                        Id   = model.Id,
                        Name = model.SeoUrl
                    });
                }

                ViewBag.ReturnUrl = this.Url.RouteUrl("Default", new { action = "AddPage", controller = "Content", id = model.SeoUrl });

                _pagesService.Update(model.ToBll(seoUrl));

                return(this.View(model));
            }

            if (_seoService.Get(model.SeoUrl) != null)
            {
                ModelState.AddModelError("SeoUrl", "Url is already defined");
                return(this.View(model));
            }

            ViewBag.ReturnUrl = this.Url.Action("AddPage", "Content");

            var seo = _seoService.Create(new BllSeo
            {
                Name = model.SeoUrl
            });

            _pagesService.Create(model.ToBll(seo));

            return(this.View(model));
        }
Exemplo n.º 4
0
 public void Update(BllSeo entity)
 {
     _repository.Update(entity.ToDB());
 }
Exemplo n.º 5
0
 public BllSeo Create(BllSeo entity)
 {
     return(_repository.Create(entity.ToDB())?.ToBll());
 }