public int UpdateSectionBySectionId(SectionDto sec) { int value = 0; using (var connection = new SqlConnection(_sqlConnStr)) { connection.Open(); var cmd = new SqlCommand("SP_UpdateSectionBySectionId", connection); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@SectionId", sec.SectionId)); cmd.Parameters.Add(new SqlParameter("@SectionName", sec.SectionName)); cmd.Parameters.Add(new SqlParameter("@RequiredCount", sec.RequiredCount)); value = cmd.ExecuteNonQuery(); connection.Close(); } return(value); }
public async Task <ActionResult> InsertSection([FromBody] SectionDto toInsert) { if (!this.HttpContext.Session.HasSystemActionRights() || !this.HttpContext.Session.HasSystemActionRight(ActionRights.SystemManagement)) { return(RedirectToAction("Index", "Home")); } var sectionId = await SectionManager.AddNewSectionAsync(toInsert); if (sectionId > 0) { _cache.Remove(CacheKeys.AllSections); toInsert.SectionID = sectionId; } // jsGrid requires the inserted object as return value. return(Json(toInsert)); }
public override SectionDto CreateDto(TestContext context) { var format = (FormatFunc)context.Formatter.Format; // Initialize the data-table; var section = new SectionDto { Heading = format(Heading), Table = new TripleTableDto(new[] { ColumnDto.Create <string>("Property"), ColumnDto.Create <string>("Value") }) }; var table = section.Table; table.Body.Add("Type", context.DataSource.GetType().Name); table.Body.Add("Query", context.Query); table.Body.Add("RowCount", context.Data.Rows.Count.ToString()); table.Body.Add("Elapsed", format($"{RuntimeVariable.TestCounter.GetDataElapsed.ToString(TimespanFormat)}")); var hasTimestampColumn = context.Data.Columns.Contains(TimestampColumn); var hasRows = context.Data.Rows.Count > 0; // If there are no rows Min/Max will throw. if (hasTimestampColumn && hasRows) { var timestampMin = context.Data.AsEnumerable().Min(r => r.Field <DateTime>(TimestampColumn)); var timestampMax = context.Data.AsEnumerable().Max(r => r.Field <DateTime>(TimestampColumn)); table.Body.Add(new List <string> { "Timestamp: min", timestampMin.ToString(CultureInfo.InvariantCulture) }); table.Body.Add(new List <string> { "Timestamp: max", timestampMax.ToString(CultureInfo.InvariantCulture) }); var timespan = timestampMax - timestampMin; table.Body.Add(new List <string> { "Timespan", timespan.ToString(TimespanFormat, CultureInfo.InvariantCulture) }); } return(section); }
public List <SectionDto> GetAllSections() { var objSectionList = new List <SectionDto>(); using (var connection = new SqlConnection(_sqlConnStr)) { connection.Open(); var cmd = new SqlCommand("SP_GetAllSections", connection); cmd.CommandType = CommandType.StoredProcedure; SqlDataReader drSection = cmd.ExecuteReader(CommandBehavior.CloseConnection); if (drSection.HasRows) { while (drSection.Read()) { var objSection = new SectionDto(); if (drSection["SectionId"] != null) { objSection.SectionId = Convert.ToInt32(drSection["SectionId"]); } if (drSection["RequiredCount"] != null) { objSection.RequiredCount = Convert.ToInt32(drSection["RequiredCount"]); } if (drSection["TotalCount"] != null) { objSection.TotalCount = Convert.ToInt32(drSection["TotalCount"]); } if (drSection["SectionName"] != null) { objSection.SectionName = Convert.ToString(drSection["SectionName"]); } if (drSection["CreatedDate"] != null) { objSection.CreatedDate = Convert.ToDateTime(drSection["CreatedDate"]); } objSectionList.Add(objSection); } } connection.Close(); } return(objSectionList); }
/// <summary> /// Modifies the given section's name and description /// </summary> /// <param name="toUpdate">the dto containing the values to update the associated entity with</param> /// <returns>True if succeeded, false otherwise</returns> public static async Task <bool> ModifySectionAsync(SectionDto toUpdate) { if (toUpdate == null) { return(false); } var section = await SectionGuiHelper.GetSectionAsync(toUpdate.SectionID); if (section == null) { return(false); } section.UpdateFromSection(toUpdate); using (var adapter = new DataAccessAdapter()) { return(await adapter.SaveEntityAsync(section).ConfigureAwait(false)); } }
private SectionDto GetSectionByUrlSlug(FormDto form, string sectionUrlSlug) { SectionDto slugSection = null; IEnumerable <SectionDto> sections = form.Sections.Select(s => s.Section); if (sectionUrlSlug != null) { int i = 0; foreach (var sectionUrlSlugPart in GetSectionUrlSlugParts(sectionUrlSlug)) { if (i % 2 == 0) { slugSection = sections.First(s => s.UrlSlug == sectionUrlSlugPart); if (slugSection == null) { return(null); } sections = slugSection.Sections.Select(s => s.ChildSection); } else if (i % 2 == 1) { //index //number } i++; } if (i % 2 != 0) { return(null); } } else if (sections.Count() > 0) { slugSection = sections.First(); } return(slugSection); }
/// <summary> /// Adds a new section to the forum system. /// </summary> /// <param name="toInsert">The dto with the values to insert</param> /// <returns> /// the SectionID of the new section. Or Zero if failed /// </returns> public static async Task <int> AddNewSectionAsync(SectionDto toInsert) { if (toInsert == null) { return(0); } var section = new SectionEntity { SectionName = toInsert.SectionName, SectionDescription = toInsert.SectionDescription, OrderNo = toInsert.OrderNo }; using (var adapter = new DataAccessAdapter()) { var result = await adapter.SaveEntityAsync(section).ConfigureAwait(false); return(result ? section.SectionID : 0); } }
public IActionResult AddSection([FromBody] SectionDto sectionDto) { var section = _mapper.Map <Section>(sectionDto); //Company company = new Company() //{ // Name = companyDto.Name, // CategoryId = companyDto.CategoryId, // Section = companyDto.Section, // FunctionCode = companyDto.FunctionCode //}; try { _service.Create(section); return(Ok("Records Added Successfully.. ")); } catch (AppException ex) { return(BadRequest(new { message = ex.Message })); } }
public async Task <MergeContextualDataForContracts> GetContextualDataForSelectedContractsAsync(string company, long[] sectionIds, int?dataVersionId = null, bool isCostNeeded = false) { var queryParameters = new DynamicParameters(); queryParameters.Add("@Section", AddValuesToUDTTSection(sectionIds)); queryParameters.Add(DataVersionIdParameter, dataVersionId); queryParameters.Add("@CompanyId", company); queryParameters.Add("@IsCostOutput", isCostNeeded); List <TradeMergeMessageDto> tradeMergeMessages = new List <TradeMergeMessageDto>(); MergeContextualDataForContracts mergeContextualData = new MergeContextualDataForContracts(); using (var contextualData = await ExecuteQueryMultipleAsync(StoredProcedureNames.GetContexualDataForSelectedContractMerge, queryParameters)) { if (contextualData != null) { IEnumerable <SectionDto> mergeDetails = await contextualData.ReadAsync <SectionDto>(); if (mergeDetails != null) { SectionDto mergeToTradeDetail = mergeDetails.First(); GetWarningMessages(mergeDetails, mergeToTradeDetail, tradeMergeMessages); GetBlockingMessages(mergeDetails, mergeToTradeDetail, tradeMergeMessages); if (isCostNeeded) { if (!contextualData.IsConsumed) { mergeContextualData.CostContextualData = await contextualData.ReadAsync <CostDto>(); } mergeContextualData.SectionContextualData = mergeDetails; } mergeContextualData.TradeMergeMessages = tradeMergeMessages; } } } return(mergeContextualData); }
/// <summary> /// adds a new section to the database /// </summary> /// <param name="dto"></param> /// <returns></returns> public async Task <AlpApiResponse <SectionDto> > InsertNewSection(SectionDto dto) { var response = new AlpApiResponse <SectionDto>(); try { _logger.LogDebug(new { action = nameof(InsertNewSection), dto = dto?.ToString() }.ToString()); dto.Validate(); var entity = dto.DtoToEntity(); entity.Floor = null; entity.Department = null; await _context.Section.AddAsync(entity); await _context.SaveChangesAsync(); response.Value = entity.EntityToDto(); } catch (Exception e) { _logger.LogError(new { exception = e, message = e.Message, innerException = e, innerExceptionMessage = e.InnerException?.Message }.ToString()); response.Message = e.Message; response.Success = false; } return(response); }
/// <summary> /// updates a section by dto /// </summary> /// <param name="dto"></param> /// <returns></returns> public async Task <AlpApiResponse> UpdateSection(SectionDto dto) { var response = new AlpApiResponse(); try { _logger.LogDebug(new { action = nameof(UpdateSection), dto = dto?.ToString() }.ToString()); dto.Validate(); var updatedEntity = await _context.Section .Include(section => section.Floor) .Include(section => section.Department) .FirstOrDefaultAsync(section => section.SectionId == dto.Id); updatedEntity.UpdateEntityByDto(dto); await _context.SaveChangesAsync(); } catch (Exception e) { _logger.LogError(new { exception = e, message = e.Message, innerException = e, innerExceptionMessage = e.InnerException?.Message }.ToString()); response.Message = e.Message; response.Success = false; } return(response); }
public SectionDto GetSectionBySectionId(int sectionId) { var objSection = new SectionDto(); using (var connection = new SqlConnection(_sqlConnStr)) { connection.Open(); var cmd = new SqlCommand("SP_GetSectionBySectionId", connection); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@SectionId", sectionId)); SqlDataReader drSection = cmd.ExecuteReader(CommandBehavior.CloseConnection); if (drSection.HasRows) { while (drSection.Read()) { if (drSection["SectionId"] != null) { objSection.SectionId = Convert.ToInt32(drSection["SectionId"]); } if (drSection["RequiredCount"] != null) { objSection.RequiredCount = Convert.ToInt32(drSection["RequiredCount"]); } if (drSection["SectionName"] != null) { objSection.SectionName = Convert.ToString(drSection["SectionName"]); } if (drSection["CreatedDate"] != null) { objSection.CreatedDate = Convert.ToDateTime(drSection["CreatedDate"]); } } } connection.Close(); } return(objSection); }
public GetPagesForSection(SectionDto section) { Section = section; }
/// <summary> /// This is only being used by Update Section Details. Previously it was overriding a core method, but that has been /// refactored out of version 6.0 /// </summary> /// <param name="section">Section Data Object</param> protected void RefreshSectionDetails(SectionDto section) { GetSortFieldDelegate<SectionDetailDto> getReference = (SectionDetailDto o) => (o.Data as ISectionDetail).SectionDetailTypeCode + (o.Data as ISectionDetail).ExternalReference; ArgumentCheck.ArgumentNullCheck(getReference, "Sort Delegate should not be null"); section.SortedSectionDetails.Clear(); if (section.SectionDetails != null) { section.SectionDetails.Sort<SectionDetailDto>((a, b) => string.Compare(getReference(a), getReference(b))); foreach (SectionDetailDto sectionDetail in section.SectionDetails) { section.SortedSectionDetails.Add(sectionDetail); } } this.riskModel.InvokePropChanged("SortedSectionDetails"); }
private void OnSectionSelected(SectionSelected message) { _selectedSection = message.Section; }
public SectionSelected(SectionDto section) { Section = section; }
/// <summary> /// Updates section data. /// </summary> /// <param name="dto">The section DTO.</param> /// <param name="locDto">The section localization DTO.</param> /// <exception cref="System.ArgumentNullException">The input DTO is null.</exception> /// <exception cref="System.Data.DBConcurrencyException">Indicates stale data.</exception> public void UpdateSectionWithLocalization(SectionDto dto, SectionLocalizationDto locDto) { if (dto == null) throw new ArgumentNullException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "dto")); const string CommandText = @" UPDATE [dbo].[Sections] SET [ProcessId] = @p_ProcessId ,[Guid] = @p_Guid ,[PaperclipsEnabled] = @p_PaperclipsEnabled ,[Position] = @p_Position WHERE [Id] = @p_Id "; using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false)) { var connection = ctx.Connection; using (var command = new SqlCommand(CommandText, connection)) { command.Parameters.AddWithValue("@p_ProcessId", dto.ProcessId); command.Parameters.AddWithValue("@p_Guid", dto.Guid); command.Parameters.AddWithValue("@p_Id", dto.Id); command.Parameters.AddWithValue("@p_PaperclipsEnabled", dto.PaperclipsEnabled); command.Parameters.AddWithValue("@p_Position", dto.Position); using (var reader = new SafeDataReader(command.ExecuteReader())) { if (reader.RecordsAffected == 0) { throw new DBConcurrencyException(Resources.StaleDataException); } } } } UpdateSectionLocalization(locDto); }
public async Task <ResultDto <bool> > Edit(SectionDto section) { return(await _client.PostJsonAsync <ResultDto <bool> >($"/api/sections/{section.Id}", section)); }
private static void FormatCsv(StringBuilder buffer, SectionDto item) { buffer.AppendLine($"{item.Id},\"{item.Name}\""); }
private static void SetBlockingMessageDetails(SectionDto mergeToTrade, List <TradeMergeMessageDto> tradeMergeMessages, SectionDto mergeDetail) { List <string> blockingInputValues = new List <string>(); if (mergeDetail.IsClosed != mergeToTrade.IsClosed) { blockingInputValues.Add(BlockingInputValues.OpenClosed); } if (mergeDetail.DepartmentId != mergeToTrade.DepartmentId) { blockingInputValues.Add(BlockingInputValues.Department); } if (mergeDetail.CounterpartyReference != mergeToTrade.CounterpartyReference) { blockingInputValues.Add(BlockingInputValues.Counterparty); } if (mergeDetail.BlDate != mergeToTrade.BlDate) { blockingInputValues.Add(BlockingInputValues.BLDate); } if (mergeDetail.CharterCode != mergeToTrade.CharterCode) { blockingInputValues.Add(BlockingInputValues.CharterReference); } if (mergeDetail.PrincipalCommodity != mergeToTrade.PrincipalCommodity) { blockingInputValues.Add(BlockingInputValues.Commodity1); } if (mergeDetail.WeightUnitId != mergeToTrade.WeightUnitId) { blockingInputValues.Add(BlockingInputValues.QuantityCode); } if (mergeDetail.PricingMethod != mergeToTrade.PricingMethod) { blockingInputValues.Add(BlockingInputValues.PriceMethod); } if (mergeDetail.Currency != mergeToTrade.Currency) { blockingInputValues.Add(BlockingInputValues.Currency); } if (mergeDetail.PriceUnitId != mergeToTrade.PriceUnitId) { blockingInputValues.Add(BlockingInputValues.PriceCode); } if (mergeDetail.Price != mergeToTrade.Price) { blockingInputValues.Add(BlockingInputValues.Price); } if (blockingInputValues != null && blockingInputValues.Any()) { TradeMergeMessageDto tradeMergeMessage = new TradeMergeMessageDto(); tradeMergeMessage.SectionId = mergeDetail.SectionId; tradeMergeMessage.ContractSectionCode = mergeDetail.ContractSectionCode; tradeMergeMessage.BlockingOrWarningInput = blockingInputValues; tradeMergeMessage.IsBlocking = true; tradeMergeMessages.Add(tradeMergeMessage); } }
public async Task <ImmutableArray <PageDto> > GetPagesForSection(SectionDto section) { var actor = ActorSystem.ActorOf(ActorRegistry.Page); return(await GetPagesForSection(actor, section)); }
/// <summary> /// Reads sections. /// </summary> /// <param name="process">The process.</param> /// <param name="reader">The reader.</param> private void ReadSections(ProcessEditDto process, SafeDataReader reader) { reader.NextResult(); while (reader.Read()) { var sectionDto = new SectionDto { Id = reader.GetInt32(0), Name = reader.GetString(1), Guid = reader.GetGuid(2), PaperclipsEnabled = reader.GetBoolean(3), IsBase = reader.GetBoolean(4), Position = reader.GetDouble(6) }; process.Sections.Add(sectionDto); } Profiler.Profile(() => this.ReadFields(process, reader)); }
private static void SetWarningMessageDetails(SectionDto mergeToTrade, List <TradeMergeMessageDto> tradeMergeMessages, SectionDto mergeDetail) { List <string> warningInputValues = new List <string>(); if (!string.IsNullOrEmpty(mergeDetail.PremiumDiscountCurrency) && !string.IsNullOrEmpty(mergeToTrade.PremiumDiscountCurrency) && (mergeDetail.PremiumDiscountCurrency != mergeToTrade.PremiumDiscountCurrency)) { warningInputValues.Add(WarningInputValues.PremiumDiscountCurrency); } if (mergeDetail.PremiumDiscountTypeId != mergeToTrade.PremiumDiscountTypeId) { warningInputValues.Add(WarningInputValues.PremiumDiscountType); } if (mergeDetail.PremiumDiscountValue != mergeToTrade.PremiumDiscountValue) { warningInputValues.Add(WarningInputValues.PremiumDiscountValue); } if (mergeDetail.ContractTermId != mergeToTrade.ContractTermId) { warningInputValues.Add(WarningInputValues.ContractTerm); } if (mergeDetail.Part2 != mergeToTrade.Part2) { warningInputValues.Add(WarningInputValues.Commodity2); } if (mergeDetail.Part3 != mergeToTrade.Part3) { warningInputValues.Add(WarningInputValues.Commodity3); } if (mergeDetail.Part4 != mergeToTrade.Part4) { warningInputValues.Add(WarningInputValues.Commodity4); } if (mergeDetail.Part5 != mergeToTrade.Part5) { warningInputValues.Add(WarningInputValues.Commodity5); } if (warningInputValues != null && warningInputValues.Any()) { TradeMergeMessageDto tradeMergeMessage = new TradeMergeMessageDto(); tradeMergeMessage.SectionId = mergeDetail.SectionId; tradeMergeMessage.ContractSectionCode = mergeDetail.ContractSectionCode; tradeMergeMessage.BlockingOrWarningInput = warningInputValues; tradeMergeMessage.IsWarning = true; tradeMergeMessages.Add(tradeMergeMessage); } }
public Task <SectionDto> CreateOrUpdateSection(SectionDto dto) { throw new NotImplementedException(); }
public int Add(SectionDto sectionDto) { var conference = _mapper.Map <Section>(sectionDto); return(_sectionRepository.Add(conference)); }
public async Task <SectionDto> CreateOrUpdateSection(string examId, SectionDto dto) { return(await _service.CreateOrUpdateSection(dto)); }
private ImmutableArray <PageDto> SetParentSectionAndNotebook(ImmutableArray <PageDto> pages, SectionDto section) { pages.ForEach(page => { page.ParentSection = section; page.ParentNotebook = section.ParentNotebook; }); return(pages); }
public async Task <ImmutableArray <PageDto> > GetPagesForSection(IActorRef actor, SectionDto section) { var answer = await actor.Ask(new PageActor.GetPagesForSection(section)); if (answer is PageActor.GetPagesForSectionResult) { var result = answer as PageActor.GetPagesForSectionResult; return(result.Pages); } LogFailure(answer); return(ImmutableArray <PageDto> .Empty); }
public static Section FromDto(this SectionDto p) => new Section() { Id = p.Id, Name = p.Name };
public async Task <Object> GetSection(int sectionId, int courseId) { if (!_sectionRepository.SectionExists(sectionId)) { return(NotFound()); } if (!ModelState.IsValid) { return(BadRequest()); } var section = new Section(); section = _sectionRepository.GetSection(sectionId); if (section == null) { return(BadRequest()); } string userId = User.Claims.First(c => c.Type == "UserID").Value; var user = await _userManager.FindByIdAsync(userId); var userRole = await _userManager.GetRolesAsync(user); var myCourses = _enrollmentRepository.GetMyCourses(userId).ToList(); bool approvedForStudent = false; var sectionDto = new SectionDto() { Id = section.Id, Title = section.Title, Videos = section.Videos }; if (userRole[0].Equals("Admin") || userRole[0].Equals("Mentor")) { return(Ok(sectionDto)); } if (userRole[0].Equals("Student")) { foreach (var course in myCourses) //all the courses in myCourses are approved by the admin { if (courseId == course.Id) { approvedForStudent = true; break; } } if (approvedForStudent) { return(Ok(sectionDto)); } else //if the course is not approved { return(Ok("You can't view the content of this course," + "order the course, or follow your pre-existing order")); } } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } //otherwise return(Ok("Please Sign Up!")); }
public async Task <ResultDto <SectionDto> > Create(SectionDto section) { return(await _client.PutJsonAsync <ResultDto <SectionDto> >("/api/sections", section)); }
/// <summary> /// Inserts section. /// </summary> /// <param name="dto">The section DTO.</param> /// <exception cref="System.ArgumentNullException">The input DTO is null.</exception> /// <exception cref="System.Data.DBConcurrencyException">Indicates stale data.</exception> public void InsertSection(SectionDto dto) { if (dto == null) throw new ArgumentNullException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "dto")); using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false)) { var connection = ctx.Connection; const string CommandText = @" INSERT INTO [dbo].[Sections] ( [Name] ,[ProcessId] ,[Guid] ,[PaperclipsEnabled] ,[Position] ) VALUES ( @p_Name ,@p_ProcessId ,@p_Guid ,@p_PaperclipsEnabled ,@p_Position ) SET @p_id = SCOPE_IDENTITY()"; using (var command = new SqlCommand(CommandText, connection)) { command.Parameters.AddWithValue("@p_Name", dto.Name); command.Parameters.AddWithValue("@p_ProcessId", dto.ProcessId); command.Parameters.AddWithValue("@p_Guid", dto.Guid); command.Parameters.AddWithValue("@p_PaperclipsEnabled", dto.PaperclipsEnabled); command.Parameters.AddWithValue("@p_Position", dto.Position); var idParam = new SqlParameter("@p_id", SqlDbType.Int, 0, "Id") { Direction = ParameterDirection.Output }; command.Parameters.Add(idParam); var rowsAffetcted = command.ExecuteNonQuery(); if (rowsAffetcted == 0) { throw new DBConcurrencyException(Resources.StaleDataException); } dto.Id = (int)idParam.Value; } } }
public SectionViewModel() { SectionDto = new SectionDto(); ParentForSectionTypes = new List <SectionTypeDto>(); Parents = new List <SectionDto>(); }
/// <summary>Initializes a new instance of the <see cref="AssessmentViewModel" /> class.</summary> /// <param name="assessmentSectionSummaryDto">The assessment section summary dto.</param> /// <param name="currentSectionDto">The current section dto.</param> public AssessmentViewModel(AssessmentSectionSummaryDto assessmentSectionSummaryDto, SectionDto currentSectionDto) { AssessmentSectionSummaryDto = assessmentSectionSummaryDto; CurrentSectionDto = currentSectionDto; }