Esempio n. 1
0
        public SuPageSectionLanguageModel UpdatePageSectionLanguage(SuPageSectionLanguageModel suPageSectionLanguageChanges)
        {
            var changedPageSectionLanguage = context.DbPageSectionLanguage.Attach(suPageSectionLanguageChanges);

            changedPageSectionLanguage.State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            context.SaveChanges();
            return(suPageSectionLanguageChanges);
        }
Esempio n. 2
0
        public IActionResult LanguageCreate(SuObjectAndStatusViewModel test3)
        {
            if (ModelState.IsValid)
            {
                var PageSectionLanguage = new SuPageSectionLanguageModel
                {
                    Name          = test3.SuObject.Name,
                    Description   = test3.SuObject.Description,
                    MouseOver     = test3.SuObject.MouseOver,
                    PageSectionId = test3.SuObject.ObjectId,
                    LanguageId    = test3.SuObject.LanguageId
                };

                _pageSectionLanguage.AddPageSectionLanguage(PageSectionLanguage);
            }
            return(RedirectToAction("LanguageIndex", new { Id = test3.SuObject.ObjectId.ToString() }));
        }
Esempio n. 3
0
        public async Task <IActionResult> Create(PageSectionAndStatusViewModel NewLevel)
        {
            if (ModelState.IsValid)
            {
                var CurrentUser = await _userManager.GetUserAsync(User);


                var TestForNull = (

                    from l in _pageSection.GetAllPageSections()
                    where l.Id == NewLevel.SuObject.ObjectId
                    select l.Sequence).Count();

                int MaxLevelSequence;

                if (TestForNull == 0)
                {
                    MaxLevelSequence = 1;
                }
                else
                {
                    MaxLevelSequence = (

                        from c in _pageSection.GetAllPageSections()
                        where c.PageId == NewLevel.SuObject.ObjectId
                        select c.Sequence).Max();
                    MaxLevelSequence++;
                }

                if (NewLevel.SuObject.Sequence != MaxLevelSequence)
                {
                    //Here need to update other levels to make sequence correct
                    //https://stackoverflow.com/questions/812630/how-can-i-reorder-rows-in-sql-database

                    List <IdAndSequence> ExistingLevels = (from c in _pageSection.GetAllPageSections()
                                                           where c.PageId == NewLevel.SuObject.ObjectId &&
                                                           c.Sequence >= NewLevel.SuObject.Sequence
                                                           select new IdAndSequence
                    {
                        Id = c.Id
                        ,
                        Sequence = c.Sequence
                    }).ToList();


                    int x = 0;
                    while (x < ExistingLevels.Count())
                    {
                        SuPageSectionModel u = new SuPageSectionModel();
                        u = _pageSection.GetPageSection(ExistingLevels[x].Id);


                        u.Sequence = ++ExistingLevels[x].Sequence;

                        _pageSection.UpdatePageSection(u);
                        x++;
                    }
                }
                var PageSection = new SuPageSectionModel
                {
                    Sequence                    = NewLevel.SuObject.Sequence,
                    PageId                      = NewLevel.SuObject.ObjectId,
                    PageSectionTypeId           = NewLevel.SuObject.Type,
                    ShowSectionTitleName        = NewLevel.SuObject.ShowSectionTitle,
                    ShowSectionTitleDescription = NewLevel.SuObject.ShowSectionDescription,
                    ShowContentTypeTitle        = NewLevel.SuObject.ShowContentTypeTitle,
                    ShowContentTypeDescription  = NewLevel.SuObject.ShowContentTypeTitleDescription,
                    OneTwoColumns               = NewLevel.SuObject.OneTwoColumns
                };
                if (NewLevel.SuObject.ContentTypeId != 0)
                {
                    PageSection.ContentTypeId = NewLevel.SuObject.ContentTypeId;
                }
                PageSection.SortById   = NewLevel.SuObject.SortById;
                PageSection.MaxContent = NewLevel.SuObject.MaxContent;
                PageSection.HasPaging  = NewLevel.SuObject.HasPaging;

                var NewPageSection = _pageSection.AddPageSection(PageSection);

                var PageSectionLanguage = new SuPageSectionLanguageModel
                {
                    Name             = NewLevel.SuObject.Name,
                    Description      = NewLevel.SuObject.Description,
                    TitleName        = NewLevel.SuObject.Title,
                    TitleDescription = NewLevel.SuObject.TitleDescription,
                    MouseOver        = NewLevel.SuObject.MouseOver,
                    PageSectionId    = NewPageSection.Id,
                    LanguageId       = CurrentUser.DefaultLanguageId
                };
                _pageSectionLanguage.AddPageSectionLanguage(PageSectionLanguage);
            }


            return(RedirectToAction("Index", new { Id = NewLevel.SuObject.ObjectId.ToString() }));
        }
Esempio n. 4
0
 public SuPageSectionLanguageModel AddPageSectionLanguage(SuPageSectionLanguageModel suPageSectionLanguage)
 {
     context.DbPageSectionLanguage.Add(suPageSectionLanguage);
     context.SaveChanges();
     return(suPageSectionLanguage);
 }