public bool UpdateRisk(Risk risk) { SqlForRisk sqlForRisk = new SqlForRisk(); bool ok = sqlForRisk.UpdateRisk(risk, CurrentUser); return(ok); }
public bool InsertRisk(Risk risk) { SqlForRisk sqlForRisk = new SqlForRisk(); bool ok = sqlForRisk.InsertRisk(risk, CurrentUser); return(ok); }
public bool DeleteRisk(Risk risk) { SqlForRisk sqlForRisk = new SqlForRisk(); bool ok = sqlForRisk.DeleteRisk(risk); return(ok); }
public RiskDetails(Risk risk) { InitializeComponent(); pictView.IsVisible = false; videoView.IsVisible = false; AgreeLabel.Text = AppReses.LangResources.ContinueButton; BackgroundColor = Color.FromHex("#efefef"); Header.Text = risk.Name; RiskId = risk.Id_r; textDetails.Text = risk.Content; showImagesButton.Text = AppReses.LangResources.ShowImages; showVideosButton.Text = AppReses.LangResources.ShowVideo; var allMedia = Utils.DeserializeFromJson <List <Media> >((string)Application.Current.Properties["AllMedia"]).FindAll(m => m.Id_r == risk.Id_r && m.Lang == AppReses.LangResources.Language); var temp_imagesList = allMedia.FindAll(m => m.Type == "image"); imagesList = new List <Media>(); foreach (var im in temp_imagesList) { imagesList.Add(new Media { Id_r = im.Id_r, Lang = im.Lang, Type = im.Type, Url = im.Url, Width = 200, Text = im.Text }); } videosList = allMedia.FindAll(m => m.Type == "video"); pictView.ItemsSource = imagesList; videoView.ItemsSource = videosList; }
private void concludeButton_Click(object sender, EventArgs e) { string safetyMeasures = ""; foreach (string item in safetyMeasuresListBox.Items.Cast <String>().ToList()) { safetyMeasures += item + "\n"; } createdRisk = new Risk( riskComboBox.Text, dangerComboBox.Text, safetyMeasures, frequencyClassificationComboBox.Text, severityClassificationComboBox.Text); try { createdRisk.CheckValidity(); Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); createdRisk = null; } }
public async Task <IActionResult> Edit(int id, [Bind("Id,RegisterId,DateRaised,Name,Description,Status,ImpactId,ProbabilityId,SeverityId")][FromBody] Risk risk) { if (id != risk.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(risk); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RiskExists(risk.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(Json(risk)); }
public void UpdateRisk(string projectUId, string riskUId, Risk risk) { // verify permission set authorizationService.VerifyPermissionAtProject(projectUId, PermissionSets.SCRUM_MASTER); risk.UpdatedAt = DateTime.Now; projectsRepository.SaveRisk(risk); }
protected override void PrepareData() { DevKit.Store.CapServerProviders = DevKit.Store.CapServerProviders .Where(x => x.DataSchemaVersion == OptionsIn.DataVersion.Version131.Value) .ToArray(); Well = new Well { Uid = DevKit.Uid(), Name = DevKit.Name("Well"), TimeZone = DevKit.TimeZone }; Wellbore = new Wellbore { Uid = DevKit.Uid(), Name = DevKit.Name("Wellbore"), UidWell = Well.Uid, NameWell = Well.Name, MDCurrent = new MeasuredDepthCoord(0, MeasuredDepthUom.ft) }; Risk = new Risk { Uid = DevKit.Uid(), Name = DevKit.Name("Risk"), UidWell = Well.Uid, NameWell = Well.Name, UidWellbore = Wellbore.Uid, NameWellbore = Wellbore.Name }; QueryEmptyList = DevKit.List(new Risk()); }
public ActionResult Edit([Bind(Include = "ID,EconomicGroup,ParentName,FleetNumber,CreditLine,Currency,ExchangeRate,Obligor,ExpirationDate,OutstandingBalance,WorkProgress,InFlight,Sum,IdEconomicGroup,IdParentName")] Risk risk) { if (ModelState.IsValid) { risk.Created = DateTime.Now; var userIdValue = Environment.UserName; var claimsIdentity = User.Identity as ClaimsIdentity; if (claimsIdentity != null) { // the principal identity is a claims identity. // now we need to find the NameIdentifier claim var userIdClaim = claimsIdentity.Claims .FirstOrDefault(x => x.Type == ClaimTypes.Name); if (userIdClaim != null) { userIdValue = userIdClaim.Value; } } risk.CreatedBy = userIdValue; db.Entry(risk).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("List")); } return(View(risk)); }
public void TestSetUp() { Logger.Debug($"Executing {TestContext.TestName}"); DevKit = new DevKit200Aspect(TestContext); Well = new Well { Uuid = DevKit.Uid(), Citation = DevKit.Citation("Well"), GeographicLocationWGS84 = DevKit.Location(), SchemaVersion = "2.0", TimeZone = DevKit.TimeZone }; Wellbore = new Wellbore { Uuid = DevKit.Uid(), Citation = DevKit.Citation("Wellbore"), Well = DevKit.DataObjectReference(Well), SchemaVersion = "2.0" }; Risk = new Risk { Uuid = DevKit.Uid(), Citation = DevKit.Citation("Risk"), Wellbore = DevKit.DataObjectReference(Wellbore), SchemaVersion = EtpUris.GetUriFamily(typeof(Risk)).Version, }; BeforeEachTest(); OnTestSetUp(); }
public async Task Risk131_PutObject_Can_Add_Risk() { AddParents(); await RequestSessionAndAssert(); var handler = _client.Handler <IStoreCustomer>(); var uri = Risk.GetUri(); var dataObject = CreateDataObject <RiskList, Risk>(uri, Risk); // Get Object Expecting it Not to Exist await GetAndAssert(handler, uri, Energistics.Etp.EtpErrorCodes.NotFound); // Put Object await PutAndAssert(handler, dataObject); // Get Object var args = await GetAndAssert(handler, uri); // Check Data Object XML Assert.IsNotNull(args?.Message.DataObject); var xml = args.Message.DataObject.GetString(); var result = Parse <RiskList, Risk>(xml); Assert.IsNotNull(result); }
public static string FormatRisk(this Risk risk) { var result = "Ризик: "; switch (risk) { case Risk.VeryLow: result += "Дуже низький"; break; case Risk.Low: result += "Низький"; break; case Risk.Average: result += "Середній"; break; case Risk.High: result += "Високий"; break; case Risk.VeryHigh: result += "Дуже високий"; break; default: throw new ArgumentOutOfRangeException(nameof(risk), risk, null); } return(result); }
public async Task <IActionResult> Edit(RiskViewModel viewModel) { if (ModelState.IsValid) { Risk risk = viewModel.Risk; try { _context.Update(risk); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RiskExists(risk.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(viewModel)); }
public List <Risk> GetRiskPoint(string search) { string sql = "SELECT DISTINCT IRP.Dealer " + "FROM I_RiskPointForm IRP " + "LEFT JOIN I_ALLOWIN IA ON IA.DISTRIBUTOR = IRP.Dealer " + (string.IsNullOrEmpty(search) ? "" : " WHERE IRP.ParentObjectID like '%" + search + "%'"); System.Data.DataTable table = AppUtility.Engine.EngineConfig.CommandFactory.CreateCommand().ExecuteDataTable(sql); List <Risk> list = new List <Risk>(); if (table.Rows.Count > 0) { for (int i = 0; i < table.Rows.Count; i++) { Risk Area = new Risk(); Area.经销商名称 = table.Rows[i]["Dealer"].ToString(); //Area.Grade = table.Rows[i]["ZScore"].ToString(); //Area.渠道分类 = table.Rows[i]["Type"].ToString(); //Area.经销商分类 = table.Rows[i]["DistributorType"].ToString(); //Area.省份 = table.Rows[i]["Province"].ToString(); //Area.城市 = table.Rows[i]["City"].ToString(); list.Add(Area); } } return(list); }
public IHttpActionResult CreateRisk(Risk update) { Risk risk = repo().CreateRisk(update); if (risk == null) return NotFound(); return Ok(risk); } // CreateRisk
public async Task <ActionEnum> CalculateRisk(Risk risk) { var keptPostCode = string.Concat(risk?.KeptPostcode?.Where(x => char.IsLetterOrDigit(x)))?.ToLower() ?? string.Empty; var riskPostCode = string.Concat(risk?.Address?.Postcode?.Where(x => char.IsLetterOrDigit(x)))?.ToLower() ?? string.Empty; // If no kept postcode is provided it is assumed to be the same as the risks postcode. if (string.IsNullOrEmpty(keptPostCode) || keptPostCode == riskPostCode) { return(ActionEnum.Accept); } // You should take the risks postcode and calculate the distance to the kept postcode. var result = await _postCodeService.GetDistance(riskPostCode, keptPostCode); // If the distance is less than 10 meters you should accept the risk if (result < 10) { return(ActionEnum.Accept); } // If the distance is more than 100 meters you should decline the risk. if (result > 100) { return(ActionEnum.Decline); } // If this is more than 10 meters away you should refer the disk. return(ActionEnum.Refer); }
protected override void PrepareData() { Well = new Well { Uuid = DevKit.Uid(), Citation = DevKit.Citation("Well"), GeographicLocationWGS84 = DevKit.Location(), SchemaVersion = "2.0", TimeZone = DevKit.TimeZone }; Wellbore = new Wellbore { Uuid = DevKit.Uid(), Citation = DevKit.Citation("Wellbore"), Well = DevKit.DataObjectReference(Well), SchemaVersion = "2.0" }; Risk = new Risk { Uuid = DevKit.Uid(), Citation = DevKit.Citation("Risk"), Wellbore = DevKit.DataObjectReference(Wellbore), SchemaVersion = EtpUris.GetUriFamily(typeof(Risk)).Version, }; }
public IHttpActionResult PutRisk(int id, Risk risk) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != risk.RisksId) { return(BadRequest()); } db.Entry(risk).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!RiskExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult Risk(Guid id, Risk update) { Risk risk = repo().UpdateRisk(id, update); if (risk == null) return NotFound(); return Ok(risk); } // Risk
public IHttpActionResult DeleteRisk(Guid id) { Risk risk = repo().DeleteRisk(id); if (risk == null) return NotFound(); return Ok(risk); }
private static void GetChartDataValue(Risk r, ChartData data, int yValueId) { switch (yValueId) { case DATA_COUNT: data.Value++; break; case DATA_PROBLEVEL: data.Value += (int)r.ProbLevelId; break; case DATA_IMPACTLEVEL: data.Value += (int)r.ImpactLevelId; break; case DATA_PROBIMPACTLEVEL: data.Value += (int)r.ProbLevelId; data.Value2 += (int)r.ImpactLevelId; break; case DATA_RISKLEVEL: data.Value += (int)r.RiskLevel; break; } data.Count++; }
public void CalculateInitialPremium_ShouldCorrectlyCalculatePremium() { var risk1 = new Risk { Name = "Test risk 1", YearlyPrice = 500.0m }; var risk2 = new Risk { Name = "Test risk 2", YearlyPrice = 800.0m }; List <Risk> riskList = new List <Risk>(); riskList.Add(risk1); riskList.Add(risk2); var effectiveDate = DateTime.Now; var premium = PremiumCalculator .CalculateInitialPremium(riskList, effectiveDate, effectiveDate.AddMonths(6)); Assert.AreEqual(651.48m, premium); }
public void Should_Rollback_UnitOfWork() { var unitOfWork = new UnitOfWork(); //Given var risk = new Risk(); risk.Address1 = "Crescent"; risk.Address2 = "Tyne & Wear"; risk.Name = "Home"; risk.PostCode = "NE30"; //When var repository = CreateNewRiskRepository(); unitOfWork.BeginTransaction(); var inserted = repository.Insert(risk); //Then Assert.IsTrue(inserted); Assert.IsTrue(risk.RiskId > 0); unitOfWork.RollBackTransaction(); var riskRefreshed = repository.GetFirst(new { RiskId = risk.RiskId }); Assert.IsNull(riskRefreshed); }
/// <summary> /// Сохранение файла в БД /// </summary> /// <param name="path">Путь к файлу</param> /// <param name="numdoc">Ун документа</param> public void SaveFile(string path, int numdoc) { try { byte[] bytefile; FileInfo file = new FileInfo(path); using (FileStream mem = new FileStream(path, FileMode.Open)) { bytefile = new byte[mem.Length]; mem.Read(bytefile, 0, bytefile.Length); } var docum = new WordDocument() { Document = bytefile, IdNamedocument = numdoc, Namefile = file.Name, TypeFile = Path.GetExtension(path), Numerdocument = Guid = Guid.NewGuid() }; Risk.WordDocuments.Add(docum); Risk.SaveChanges(); } catch (Exception e) { Loggers.Log4NetLogger.Error(e); } }
public async Task <IActionResult> Edit(int id, Risk risk) { if (id != risk.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(risk); await _context.SaveChangesAsync(); TempData["Toast"] = Toasts.Saved; } catch (DbUpdateConcurrencyException) { if (!RiskExists(risk.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(risk)); }
public void AddRisk(string nameOfInsuredObject, Risk risk, DateTime validFrom, DateTime effectiveDate) { if (validFrom < effectiveDate) { throw new RiskValidityPeriodException(); } var policyId = IdGenerator.ConstructPolicyId(nameOfInsuredObject, effectiveDate); var policyModel = _policyRepository.Get(policyId); if (validFrom > policyModel.ValidTill) { throw new RiskValidityPeriodException(); } if (policyModel.InsuredRisks.Contains(risk)) { throw new DuplicateRiskException(risk.Name); } var riskId = IdGenerator.ConstructRiskId(risk.Name, policyModel.NameOfInsuredObject, effectiveDate); var riskModel = new RiskModel { Name = risk.Name, ValidFrom = validFrom, PolicyEffectiveDate = effectiveDate, PolicyId = policyId, Id = riskId, ValidTill = policyModel.ValidTill, YearlyPrice = risk.YearlyPrice }; _riskRepository.Add(riskModel); }
public void CalculatePremiumForInitialAndAdditionalSetOfRisks() { var additionalinsurancePeriod = new InsurancePeriod(DateTime.Now.AddMonths(6), 6); var additionalRisk = new Risk { Name = fixture.Create <string>(), YearlyPrice = 50 }; var riskInsuredPeriod = new RiskInsurancePeriod(additionalinsurancePeriod, additionalRisk); var insurancePeriod = new InsurancePeriod(DateTime.Now, 12); var insuredRisks = new List <Risk> { new Risk { Name = fixture.Create <string>(), YearlyPrice = 40m }, new Risk { Name = fixture.Create <string>(), YearlyPrice = 36m } }; var initialRiskSet = new InitialRiskSet(insuredRisks, insurancePeriod, riskInsuredPeriod); var premium = initialRiskSet.CalculatePremium(); Assert.Equal(101m, premium); }
public void RemoveRisk(string nameOfInsuredObject, Risk risk, DateTime validTill, DateTime effectiveDate) { var policyId = IdGenerator.ConstructPolicyId(nameOfInsuredObject, effectiveDate); var policyModel = _policyRepository.Get(policyId); if (validTill.Date > policyModel.ValidTill.Date) { throw new RiskRemovalDateException(); } var riskId = IdGenerator.ConstructRiskId(risk.Name, nameOfInsuredObject, effectiveDate); var riskModel = _riskRepository.Get(riskId); var updatedRiskModel = new RiskModel { Name = riskModel.Name, ValidFrom = riskModel.ValidFrom, PolicyEffectiveDate = riskModel.PolicyEffectiveDate, PolicyId = riskModel.PolicyId, Id = riskModel.Id, ValidTill = validTill, YearlyPrice = riskModel.YearlyPrice }; _riskRepository.Edit(updatedRiskModel); }
private void AddRiskToList(Risk r, int newProb, int newImpact, List <Risk> list) { r.ProbLevelId = newProb; r.ImpactLevelId = newImpact; r.RiskLevel = newProb * newImpact; list.Add(r); }
private static void ListTeams(Risk risk) { foreach (var t in risk.GetTeams()) { Utility.WriteLine(t.ToString()); } }
public ActionResult EditRisk(Risk risk) { if (ModelState.IsValid) { riskActions.EditRisk(risk); return View("Index"); } return View(); }
public RiskViewModel( IBackgroundExecutor executor, IProjectsService projectsService, Risk risk) { this.executor = executor; this.projectsService = projectsService; Risk = risk; ChangeRiskImpactCommand = new DelegateCommand(ChangeRiskImpact); ChangeRiskProbabilityCommand = new DelegateCommand(ChangeRiskProbability); }
private void ValidateRisk(Risk risk, bool isCreate) { var project = _contextProvider.Projects.AsNoTracking() .FirstOrDefault(p => p.ProjectId == risk.ProjectId); if (project == null) throw new NotFoundException("Project not found."); if (!isCreate) { var existing = project.Risks .FirstOrDefault(r => r.RiskId == risk.RiskId); if (existing == null) throw new NotFoundException(string.Format("Risk {0} not found.", risk.Title)); } else { var duplicate = project.Risks.FirstOrDefault(r => r.ProjectId != risk.ProjectId && r.Title.Equals(risk.Title, StringComparison.InvariantCultureIgnoreCase) && r.Description.Equals(risk.Description, StringComparison.InvariantCultureIgnoreCase)); if (duplicate != null) throw new ValidationException("Risk with same title and description exists."); } if (string.IsNullOrWhiteSpace(risk.Title)) throw new ValidationException("Missing Title."); if (risk.Title.Length > 100) throw new ValidationException("Title cannot exceed 100 characters."); if (risk.Description != null && risk.Description.Length > 300) throw new ValidationException("Description cannot exceed 300 characters."); }
public void Show(Risk risk) { Risk = risk; oldRisk = risk.Clone(); Show(projectContainer.Value); }
public void AddRisk(string projectUId, Risk risk) { var client = ClientHelper.GetClient(authorizator); HttpResponseMessage response = client.Post(Url("Projects/" + projectUId.Trim() + "/Risks"), new ObjectContent<Risk>(risk, JsonMediaTypeFormatter.DefaultMediaType)); ClientHelper.HandleHTTPErrorCode(response); }
public void ValidateRisk(Risk risk) { ValidateRisk(risk, false); }
public void ValidateNewRisk(Risk risk) { ValidateRisk(risk, true); }
private IRisk CreateRiskModelInstance(DataRow row) { Risk r = new Risk() { Id = Convert.ToInt32(row["Id"]), Title = row["Title"].ToString(), Type = GetRiskTypeById(Convert.ToInt32(row["TypeId"])) }; return r; }
public void SaveRisk(Risk risk) { using (var context = new ScrumFactoryEntities(this.connectionString)) { Risk oldRisk = GetRisk(risk.RiskUId); // if is a new item insert it if (oldRisk == null) { context.Risks.AddObject(risk); // updates the item } else { context.AttachTo("Risks", oldRisk); context.ApplyCurrentValues<Risk>("Risks", risk); } context.SaveChanges(); } }
private void AddRisk() { Risk newRisk = new Risk(); newRisk.RiskUId = Guid.NewGuid().ToString(); newRisk.ProjectUId = project.ProjectUId; newRisk.CreateDate = DateTime.Now; newRisk.UpdatedAt = DateTime.Now; newRisk.IsPrivate = false; newRisk.RiskDescription = NewRiskDescription; newRisk.Impact = (short)RiskImpacts.LOW_IMPACT_RISK; newRisk.Probability = (short)RiskProbabilities.LOW_PROBABILITY_RISK; executor.StartBackgroundTask( () => { projectsService.AddRisk(newRisk.ProjectUId, newRisk); }, () => { risks.Add(newRisk); RiskViewModel riskVM = new RiskViewModel(executor, projectsService, newRisk); FilteredRisks.Add(riskVM); riskVM.NotifyAdded(); NewRiskDescription = null; }); }
public void UpdateRisk(string projectUId, string riskUId, Risk risk) { // verify permission set authorizationService.VerifyPermissionAtProject(projectUId, PermissionSets.SCRUM_MASTER); risk.UpdatedAt = DateTime.Now; projectsRepository.SaveRisk(risk); }
public Risk Build() { var risk = new Risk { ClientReference = ClientReference, VehicleDetails = VehicleDetails, VehicleUsage = VehicleUsage, PersonalDetails = PersonDetails, Claim = Claim, Conviction = Conviction, DrivingHistory = DrivingHistory, PolicyDetails = PolicyDetails, ContactDetails = ContactDetails }; return risk; }