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(); } }
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); }
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; } }
public ActionResult AddSec(Models.Section s) { SectionBL.InsertToSec(s); Session["SecId"] = s.secId; return(RedirectToAction("AddSec")); }
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; }
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); } }
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; }
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()); }
public List <NavItem> GetNavItemsBySection(Models.Section s) { return(navItems.Where(navItem => navItem.Section == s) .OrderBy(o => o.OrderIndex).ToList()); }
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(); }
public SectionView(Models.Section section) { InitializeComponent(); Section = section; }