public async Task <ActionResult <SessionSection> > PostSessionSection([FromBody] SessionSection sessionSection) { sessionSection.UserId = User.FindFirstValue(ClaimTypes.NameIdentifier); if (sessionSection.SessionSectionName == "" || sessionSection is null) { sessionSection.SessionSectionName = "Section"; } try { Campaign selectedCampaign = await _context.Campaigns.FindAsync(sessionSection.CampaignID); if (selectedCampaign.UserId == sessionSection.UserId) { await _context.SessionSections.AddAsync(sessionSection); await _context.SaveChangesAsync(); return(CreatedAtAction("GetSessionSection", new { id = sessionSection.SessionSectionID }, sessionSection)); } else { return(BadRequest()); } } catch (Exception exc) { return(BadRequest()); } }
public async Task <ActionResult <SessionSection> > PutSessionSection(int id, SessionSection sentSessionSection) { string requestingUser = User.FindFirstValue(ClaimTypes.NameIdentifier); SessionSection sessionSection = await _context.SessionSections.FindAsync(id); if (id != sentSessionSection.SessionSectionID || sessionSection.UserId != requestingUser) { return(BadRequest()); } if (sentSessionSection.SessionSectionName != null) { sessionSection.SessionSectionName = sentSessionSection.SessionSectionName; } _context.Entry(sessionSection).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SessionSectionExists(id)) { //_logController.AddSystemLog($"WARNING: User {requestingUser} has caused a DbUpdateConcurrencyException"); return(NotFound()); } else { throw; } } return(NoContent()); }
private LibraryConfiguration(LibraryConfiguration source) { this.Highlighting = source.Highlighting.DeepCopy(); this.Date = source.Date.DeepCopy(); #if !SILVERLIGHT this.Mailer = source.Mailer.DeepCopy(); this.Session = source.Session.DeepCopy(); this.Serialization = source.Serialization.DeepCopy(); #endif }
public LibraryConfiguration() { this.Highlighting = new HighlightingSection(); this.Date = new DateSection(); #if !SILVERLIGHT this.Mailer = new MailerSection(); this.Session = new SessionSection(); this.Serialization = new SerializationSection(); #endif }
public async Task <ActionResult <SessionSection> > GetSessionSection(int id) { SessionSection sessionSection = await _context.SessionSections.FindAsync(id); if (sessionSection == null) { return(NotFound()); } return(sessionSection); }
/// <summary> /// Creates an instance of <see cref="LocalConfiguration"/> initialized by values /// copied from the specified instance. /// </summary> /// <param name="source"></param> private LocalConfiguration(LocalConfiguration source) { this.OutputControl = source.OutputControl.DeepCopy(); this.ErrorControl = source.ErrorControl.DeepCopy(); this.RequestControl = source.RequestControl.DeepCopy(); this.FileSystem = source.FileSystem.DeepCopy(); this.Assertion = source.Assertion.DeepCopy(); this.Variables = source.Variables.DeepCopy(); this.Session = source.Session.DeepCopy(); this.Library = source.Library.DeepCopy(); LastConfigurationModifiedTimeUtc = source.LastConfigurationModifiedTimeUtc; }
/// <summary> /// Creates an instance of <see cref="LocalConfiguration"/> initialized by default values. /// </summary> public LocalConfiguration() { OutputControl = new OutputControlSection(); ErrorControl = new ErrorControlSection(); RequestControl = new RequestControlSection(); FileSystem = new FileSystemSection(); Assertion = new AssertionSection(); Variables = new VariablesSection(); Session = new SessionSection(); Library = new LibraryConfigurationsSection(); LastConfigurationModifiedTimeUtc = DateTime.MinValue; }
public async Task <ActionResult <SessionSection> > DeleteSessionSection(int id) { string requestingUserId = User.FindFirstValue(ClaimTypes.NameIdentifier); SessionSection sessionSection = await _context.SessionSections.FindAsync(id); if (sessionSection.UserId != requestingUserId) { return(BadRequest()); } _context.SessionSections.Remove(sessionSection); await _context.SaveChangesAsync(); return(NoContent()); }
/// <summary> /// Creates an instance of <see cref="LocalConfiguration"/> initialized by values /// copied from the specified instance. /// </summary> /// <param name="source"></param> private LocalConfiguration(LocalConfiguration source) { this.OutputControl = source.OutputControl.DeepCopy(); this.ErrorControl = source.ErrorControl.DeepCopy(); this.RequestControl = source.RequestControl.DeepCopy(); this.FileSystem = source.FileSystem.DeepCopy(); this.Assertion = source.Assertion.DeepCopy(); this.Variables = source.Variables.DeepCopy(); this.Session = source.Session.DeepCopy(); this.Library = source.Library.DeepCopy(); LastConfigurationModificationTime = source.LastConfigurationModificationTime; }
/// <summary> /// Creates an instance of <see cref="LocalConfiguration"/> initialized by default values. /// </summary> public LocalConfiguration() { OutputControl = new OutputControlSection(); ErrorControl = new ErrorControlSection(); RequestControl = new RequestControlSection(); FileSystem = new FileSystemSection(); Assertion = new AssertionSection(); Variables = new VariablesSection(); Session = new SessionSection(); Library = new LibraryConfigurationsSection(); LastConfigurationModificationTime = DateTime.MinValue; }