Exemplo n.º 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();
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 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;
            }
        }
Exemplo n.º 4
0
        public ActionResult AddSec(Models.Section s)
        {
            SectionBL.InsertToSec(s);

            Session["SecId"] = s.secId;

            return(RedirectToAction("AddSec"));
        }
Exemplo n.º 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;
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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;
 }
Exemplo n.º 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);
        }
Exemplo n.º 9
0
        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());
        }
Exemplo n.º 10
0
 public List <NavItem> GetNavItemsBySection(Models.Section s)
 {
     return(navItems.Where(navItem => navItem.Section == s)
            .OrderBy(o => o.OrderIndex).ToList());
 }
Exemplo n.º 11
0
 public SelectControl(Models.Section section)
 {
     InitializeComponent();
     LoadControls(section);
 }
Exemplo n.º 12
0
 async public void RemoveSection(Models.Section section)
 {
     _context.Section.Remove(section);
     await _context.SaveChangesAsync();
 }
Exemplo n.º 13
0
        async public void UpdateSection(Models.Section section)
        {
            _context.Attach(section).State = EntityState.Modified;

            await _context.SaveChangesAsync();
        }
Exemplo n.º 14
0
 //Section methods
 async public void AddSection(Models.Section section)
 {
     _context.Section.Add(section);
     await _context.SaveChangesAsync();
 }
Exemplo n.º 15
0
 public SectionView(Models.Section section)
 {
     InitializeComponent();
     Section = section;
 }