示例#1
0
        private void btnCreate_Click(object sender, RoutedEventArgs e)
        {
            bool valid = true;

            if (tbName.Text == string.Empty)
            {
                valid            = false;
                lbNameError.Text = "Enter name";
            }
            else
            {
                lbNameError.Text = string.Empty;
            }

            if (valid == true)
            {
                if (!edit)
                {
                    Section = new Models.Section();
                }
                Section.Name = tbName.Text;
                Section.SectionIdentifier = sectionIdentifierSelector.SectionIdentifier;
                Section.SectionIdentifier = identifier;
                Close();
            }
        }
示例#2
0
        public bool CreateSection(MyContext context, int userId, string sectionName)
        {
            bool created = false;

            var user = GetUser(context, userId);

            try
            {
                var section = new Models.Section
                {
                    Name = sectionName,
                    SectionCreationDate = DateTime.Now.Date,
                    UserId = user.UserId
                };

                context.Sections.Add(section);
                context.SaveChanges();

                created = true;
            }
            catch (Exception e)
            {
                string error = e.Message;
            }

            return(created);
        }
示例#3
0
        public void DeleteSection(MyContext context, int sectionId, ref Boolean couldDelete)
        {
            try
            {
                List <Models.Picture> images = GetImages(context, sectionId);

                foreach (Models.Picture image in images)
                {
                    DeleteImage(context, image.PictureId);
                }

                Models.Section toDelete = new Models.Section {
                    SectionId = sectionId
                };
                context.Sections.Attach(toDelete);
                context.Sections.Remove(toDelete);
                context.SaveChanges();

                couldDelete = true;
            }
            catch (Exception e)
            {
                string error = e.Message;
            }
        }
示例#4
0
        public ActionResult AddSec(Models.Section s)
        {
            SectionBL.InsertToSec(s);

            Session["SecId"] = s.secId;

            return(RedirectToAction("AddSec"));
        }
示例#5
0
 public SectionListItem(Models.Section section, IStudioEnvironment studio)
 {
     InitializeComponent();
     Section                  = section;
     this.studio              = studio;
     lbSectionName.Text       = section.Name;
     Section.PropertyChanged += SectionPropertyChanged;
     btnRefresh.Visibility    = Section.IsLoaded ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible;
 }
示例#6
0
 private void LoadControls(Models.Section section)
 {
     foreach (Models.Control control in section.Controls)
     {
         ListBoxItem item = new ListBoxItem();
         item.Content = control.Name;
         item.Tag     = control.Id;
         lsbControls.Items.Add(item);
     }
 }
示例#7
0
 public NewSection(Models.Section section)
 {
     InitializeComponent();
     Section           = section;
     lbTitle.Text      = "Edit Section";
     btnCreate.Content = "Save";
     edit        = true;
     tbName.Text = Section.Name;
     sectionIdentifierSelector.SectionIdentifier = Section.SectionIdentifier;
     tbBaseNode.Text = section.SectionIdentifier.Name;
 }
示例#8
0
        public static List <string> GetAllIds(Models.Section section)
        {
            List <string> result = new List <string>();

            result.Add(section.Id);
            foreach (Models.Control control in section.Controls)
            {
                result.Add(control.Id);
            }
            return(result);
        }
        public async Task <IHttpActionResult> Put(Models.Section section)
        {
            ValidationError[] validationErrors = await sectionService.UpdateSectionAsync(section.DeepCopyTo <Services.SectionService.Contract.Section>());

            if (validationErrors.Any())
            {
                return(BadRequest());
            }

            return(Ok());
        }
示例#10
0
 public List <NavItem> GetNavItemsBySection(Models.Section s)
 {
     return(navItems.Where(navItem => navItem.Section == s)
            .OrderBy(o => o.OrderIndex).ToList());
 }
示例#11
0
 public SelectControl(Models.Section section)
 {
     InitializeComponent();
     LoadControls(section);
 }
 async public void RemoveSection(Models.Section section)
 {
     _context.Section.Remove(section);
     await _context.SaveChangesAsync();
 }
        async public void UpdateSection(Models.Section section)
        {
            _context.Attach(section).State = EntityState.Modified;

            await _context.SaveChangesAsync();
        }
 //Section methods
 async public void AddSection(Models.Section section)
 {
     _context.Section.Add(section);
     await _context.SaveChangesAsync();
 }
示例#15
0
 public SectionView(Models.Section section)
 {
     InitializeComponent();
     Section = section;
 }