Ejemplo n.º 1
0
        public async Task <ActionResult <HomePageSection> > PostAdminHomePageSection(HomePageSection HomePageSection)
        {
            _context.HomePageSection.Add(HomePageSection);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetHomePageSection", new { id = HomePageSection.Id }, HomePageSection));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> PutAdminHomePageSection(int id, HomePageSection AdminHomePageSection)
        {
            if (id != AdminHomePageSection.Id)
            {
                return(BadRequest());
            }

            _context.Entry(AdminHomePageSection).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AdminHomePageSectionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public void Handle(PublishHomePageSection c)
        {
            HomePageSection h = null;

            using (var db = new CoreCmsDbContext())
            {
                h = db.HomePageSections.FirstOrDefault(i => i.Id == c.Id);
                if (h == null)
                {
                    return;
                }
                h.Published = c.IsPublish;
                db.SaveChanges();
            }
        }
        public void Handle(DeleteHomPageSection c)
        {
            HomePageSection h = null;

            using (var db = new CoreCmsDbContext())
            {
                h = db.HomePageSections.FirstOrDefault(i => i.Id == c.Id);
                if (h == null)
                {
                    return;
                }
                db.HomePageSections.Remove(h);
                db.SaveChanges();
            }

            _eventPublisher.Publish(new ContentLanguageDeleted(c.Id));
        }
        public void Handle(CreateHomePageSection c)
        {
            var h = new HomePageSection();

            using (var db = new CoreCmsDbContext())
            {
                h.CategoryId              = c.CategoryId;
                h.Id                      = c.Id;
                h.CreatedDate             = DateTime.Now;
                h.DisplayOrder            = c.DisplayOrder;
                h.HomePageSectionViewName = c.ViewName;

                db.HomePageSections.Add(h);
                db.SaveChanges();
            }
            _eventPublisher.Publish(new ContentLanguageUpdated(c.Id, c.LanguageId, "Title", c.Title, "HomePageSection"));
        }
        public void Handle(UpdateHomePageSection c)
        {
            HomePageSection h = null;

            using (var db = new CoreCmsDbContext())
            {
                h = db.HomePageSections.FirstOrDefault(i => i.Id == c.Id);
                if (h == null)
                {
                    return;
                }
                h.CategoryId = c.CategoryId;

                h.DisplayOrder            = c.DisplayOrder;
                h.HomePageSectionViewName = c.ViewName;
                db.SaveChanges();
            }
            _eventPublisher.Publish(new ContentLanguageUpdated(c.Id, c.LanguageId, "Title", c.Title, "HomePageSection"));
        }