public override Dictionary <string, object> ViewDataValues(NamesHelper h) { var viewDataValues = new Dictionary <string, object>(); viewDataValues.Add("MailTo", h.GetMailList()); return(viewDataValues); }
protected override void OnActionExecuting(ActionExecutingContext filterContext) { base.OnActionExecuting(filterContext); helper = new ReportHelper(DB); h = new NamesHelper(CurrentUser.Id); }
public override Dictionary <string, object> ViewDataValues(NamesHelper h) { return(new Dictionary <string, object> { { "RegionCodeEqual", h.GetRegionList(Id) }, { "CatalogIdEqual", h.GetCatalogList() } }); }
public ActionResult Index() { var h = new NamesHelper(CurrentUser.Id); ViewBag.ListProducer = h.RegisterListProducer(); var model = DB.AccountCompany.Where(x => x.ProducerId.HasValue).ToList(); // TODO протестировать без производителя return(View(model)); }
private void CheckValidNames(string prefix, string suffix) { foreach (var validName in NamesHelper.GetValidNames(random, new Configurations.NameRules { Prefix = prefix, Suffix = suffix, Type = specificNameRulesService.NameRulesType })) { specificNameRulesService.IsNameValid(validName.Name, prefix, suffix).Should().Be(true, $"Name '{validName}' is valid"); specificNameRulesService.GetNameWords(validName.Name, prefix, suffix).SequenceEqual(validName.Words).Should().Be(true); } }
public override Dictionary <string, object> ViewDataValues(NamesHelper h) { var viewDataValues = new Dictionary <string, object>(); viewDataValues.Add("RegionCodeEqual", h.GetRegionList(Id)); viewDataValues.Add("CatalogIdEqual", h.GetCatalogList()); viewDataValues.Add("CatalogIdEqual2", h.GetCatalogList(CatalogIdEqual2)); return(viewDataValues); }
public ActionResult Index() { var h = new NamesHelper(CurrentUser.Id); var ProducerList = new List <OptionElement> { new OptionElement { Text = "<Без производителя>", Value = "" } }; var ProducerListRegistration = h.RegisterListProducer(); ProducerList.AddRange(ProducerListRegistration); return(View(ProducerList)); }
/// <summary> /// Подробнее /// </summary> /// <param name="Id">идентификатор промоакции</param> public ActionResult View(long id) { var model = DB2.Promotions.Find(id); var h = new NamesHelper(CurrentUser.Id); ViewBag.ProducerName = h.GetProducerList().Single(x => x.Value == model.ProducerId.ToString()).Text; ViewBag.RegionList = h.GetPromotionRegionNames((ulong)model.RegionMask); ViewBag.DrugList = h.GetDrugInPromotion(model.Id); ViewBag.SupplierList = h.GetSupplierList(model.PromotionsToSupplier.ToList().Select(x => (decimal)x.SupplierId).ToList()); ViewBag.History = DB2.PromotionHistory.Where(x => x.Promotion.Id == model.Id).ToList(); return(View(model)); }
/// <summary> /// Поиск промоакций по фильтру /// </summary> public ActionResult SearchResult(SearchProducerPromotion filter) { var h = new NamesHelper(CurrentUser.Id); var producerList = new List <OptionElement>() { new OptionElement { Text = "Все зарегистрированные", Value = "0" } }; producerList.AddRange(h.RegisterListProducer()); ViewBag.ProducerList = producerList; return(PartialView("Partial/Promotions", filter.Find(DB2))); }
/// <summary> /// Вывод статистики выбранного производителя /// </summary> /// <param name="Id">идентификатор AccountCompany</param> /// <returns></returns> public ActionResult GetProducerInformation(int Id) { var producerId = DB.AccountCompany.Single(x => x.Id == Id).ProducerId; var firstUserId = DB.Account.First(x => x.AccountCompany.Id == Id).Id; var h = new NamesHelper(firstUserId); ViewBag.ListProducer = h.RegisterListProducer(); ViewBag.DrugList = h.GetCatalogListPromotion(); ViewBag.ReportList = DbSession.Query <Job>().Fetch(x => x.Owner).Where(x => x.Producer.Id == producerId) .OrderByDescending(x => x.CreationDate).ToList(); var model = DB.AccountCompany.Find(Id); return(PartialView("partial/producerinformation", model)); }
public ActionResult Index() { var h = new NamesHelper(CurrentUser.Id); var producerList = new List <OptionElement>() { new OptionElement { Text = "Все зарегистрированные", Value = "0" } }; producerList.AddRange(h.RegisterListProducer()); ViewBag.ProducerList = producerList; return(View(new SearchProducerPromotion())); }
protected override void OnActionExecuting(ActionExecutingContext filterContext) { base.OnActionExecuting(filterContext); if (CurrentUser == null) { return; } helper = new ReportHelper(DB); h = new NamesHelper(CurrentUser.Id); if (CurrentUser.IsProducer) { ViewBag.Producernames = DB.producernames.Single(x => x.ProducerId == CurrentUser.AccountCompany.ProducerId) .ProducerName; } }
public void WrongCoupleWomanTest() { try { God god = new God(); Girl girl = new Girl(NamesHelper.GenerateName(Sex.Woman)); SmartGirl smartGirl = new SmartGirl(NamesHelper.GenerateName(Sex.Woman)); god.MakeCouple(girl, smartGirl); Assert.Fail("No exception"); } catch (Exception ex) { if (!(ex is WrongCoupleException)) { Assert.Fail("Not WrongCoupleException"); } } }
public void WrongCoupleManTest() { try { God god = new God(); Student student = new Student(NamesHelper.GenerateName(Sex.Man)); Botan botan = new Botan(NamesHelper.GenerateName(Sex.Man)); god.MakeCouple(student, botan); Assert.Fail("No exception"); } catch (Exception ex) { if (!(ex is WrongCoupleException)) { Assert.Fail("Not WrongCoupleException"); } } }
/// <summary> /// Updates spot vehicle list according to current spot /// </summary> private void _RefreshDealerVehicleList() { if (!string.IsNullOrEmpty(_CurrentAvailabilitySpot)) { spotVehiclesListView.Items.Clear(); // Getting spot reference if (_CurrentAvailabilitySpot.Contains(Tools.SYMBOL_VALUE_SEPARATOR.ToString())) { _CurrentAvailabilitySpot = _CurrentAvailabilitySpot.Split(Tools.SYMBOL_VALUE_SEPARATOR)[1]; } // Vehicles from this spot DB.Entry allVehicles = DatabaseHelper.SelectAllCellsFromTopicWherePrimaryKey(_CarShopsTable, _CurrentAvailabilitySpot)[0]; for (int col = 3; col < 18; col++) { int slotIndex = col - 2; ListViewItem li = new ListViewItem(slotIndex.ToString()); string vehicleRef = allVehicles.cells[col].value; string vehicleName; // Compact 1 == free slot if (DatabaseConstants.COMPACT1_PHYSICS_DB_RESID.Equals(vehicleRef)) { vehicleName = _FREE_SLOT_NAME; } else { vehicleName = NamesHelper.GetVehicleFullName(allVehicles.cells[col].value, true, _PhysicsTable, _PhysicsResource, _BrandsTable, _BrandsResource); } // Current vehicle line is in bold li.Font = (vehicleRef.Equals(_CurrentVehicle) ? new Font(spotVehiclesListView.Font, FontStyle.Bold) : new Font(spotVehiclesListView.Font, FontStyle.Regular)); li.Tag = vehicleRef; li.SubItems.Add(vehicleName); spotVehiclesListView.Items.Add(li); } } }
protected override void OnActionExecuting(ActionExecutingContext filterContext) { base.OnActionExecuting(filterContext); if (CurrentUser == null) { return; } h = new NamesHelper(CurrentUser.Id); if (CurrentUser.AccountCompany.ProducerId.HasValue) { producerId = CurrentUser.AccountCompany.ProducerId.Value; } else { ErrorMessage("Доступ в раздел Акции закрыт, так как вы не представляете кого-либо из производителей"); filterContext.Result = Redirect("~"); } }
/// <summary> /// Defines tab contents /// </summary> private void _InitializeDatasheetContents() { // Brand name string brandName = NamesHelper.GetVehicleBrandName(_CurrentVehicle, _PhysicsTable, _BrandsTable, _BrandsResource); // Real name : if it's mentioned, other names are not used ! DB.Cell realNameCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.REAL_NAME_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; if (DatabaseConstants.NOT_AVAILABLE_NAME_PHYSICS_DB_RESID.Equals(realNameCell.value)) { // Model + Version name _IsVehicleWithRealName = false; } else { // Real name _IsVehicleWithRealName = true; } // Brand logo DB.Cell brandRefCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.CAR_BRAND_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; string brandLogoName = _GetBrandLogoName(brandRefCell.value); if (File.Exists(brandLogoName)) { brandPictureBox.Image = Image.FromFile(brandLogoName); } else { brandPictureBox.Image = brandPictureBox.InitialImage; } // Vehicle name string vehicleName = NamesHelper.GetVehicleFullName(_CurrentVehicle, false, _PhysicsTable, _PhysicsResource, _BrandsTable, _BrandsResource); modelNameLabel.Text = string.Format(_FORMAT_MODEL_NAME, brandName.ToUpper(), vehicleName); // Engine type DB.Cell currentCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.ENGINE_TYPE_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; engineTypeLabel.Text = DatabaseHelper.GetResourceValueFromCell(currentCell, _PhysicsResource); // Displacement currentCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.DISPLACEMENT_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; engineDisplacementLabel.Text = currentCell.value; // Max power and rpm currentCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.POWER_BHP_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; engineMaxPowerLabel.Text = currentCell.value; currentCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.POWER_RPM_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; engineRpmPowerLabel.Text = currentCell.value; // Max torque and rpm currentCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.TORQUE_NM_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; engineMaxTorqueLabel.Text = currentCell.value; currentCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.TORQUE_RPM_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; engineRpmTorqueLabel.Text = currentCell.value; // Weight currentCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.WEIGHT_KG_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; weightLabel.Text = currentCell.value; // Tires currentCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.TYRES_TYPE_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; tiresTypeLabel.Text = DatabaseHelper.GetResourceValueFromCell(currentCell, _PhysicsResource); // Brakes currentCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.BRAKES_CHAR_FRONT_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; string brakesChar = DatabaseHelper.GetResourceValueFromCell(currentCell, _PhysicsResource); currentCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.BRAKES_DIM_FRONT_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; frontBrakesLabel.Text = string.Format(_FORMAT_BRAKES_LABEL, brakesChar, currentCell.value); currentCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.BRAKES_CHAR_REAR_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; brakesChar = DatabaseHelper.GetResourceValueFromCell(currentCell, _PhysicsResource); currentCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.BRAKES_DIM_REAR_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; rearBrakesLabel.Text = string.Format(_FORMAT_BRAKES_LABEL, brakesChar, currentCell.value); // Performance : max speed currentCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.TOP_SPEED_KMH_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; ushort slotTopSpeed = VehicleSlotsHelper.VehicleInformation[_CurrentVehicle].topSpeed; ushort currentTopSpeed = ushort.Parse(currentCell.value); // BUG_93: max speed modifications outside TDUMT _IsSpeedLimiterEnabled = (slotTopSpeed != 0); if (currentTopSpeed > slotTopSpeed) { MessageBoxes.ShowWarning(this, _WARN_MODDED_MAX_SPEED); _IsSpeedLimiterEnabled = false; } topSpeedTrackBar.Enabled = _IsSpeedLimiterEnabled; if (slotTopSpeed == 0) { topSpeedTrackBar.Maximum = currentTopSpeed; } else { topSpeedTrackBar.Maximum = slotTopSpeed; } if (_IsSpeedLimiterEnabled) { topSpeedTrackBar.Value = currentTopSpeed; } else { topSpeedTrackBar.Value = topSpeedTrackBar.Maximum; } _UpdateSpeedLimiter(); // Acceleration : 0 to 100 kph currentCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.ACCELERATION_0_100_KMH_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; datasheetAccelerationKmhTextBox.Text = currentCell.value; // Acceleration : 0 to 100 mph currentCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.ACCELERATION_0_100_MPH_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; datasheetAccelerationMphTextBox.Text = currentCell.value; // Acceleration : 0-400m currentCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.QUARTER_MILE_SEC_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; datasheetAcceleration400MTextBox.Text = currentCell.value; // Acceleration : 0-1000m currentCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.T0_TO_1000M_SEC_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; datasheetAcceleration1000MTextBox.Text = currentCell.value; }
public abstract Dictionary <string, object> ViewDataValues(NamesHelper h);
/// <summary> /// Updates vehicle list according to slots reference /// </summary> private void _RefreshVehicleList() { Cursor = Cursors.WaitCursor; vehicleListView.Items.Clear(); vehicleListView.Groups.Clear(); // Taking list mode into account (original/modded names) Dictionary <string, string> originalNamesByModdedNames = null; SortedStringCollection vehicleNames = new SortedStringCollection(); if (_IsShowOriginalNames) { foreach (string vehicleName in VehicleSlotsHelper.SlotReference.Keys) { vehicleNames.Add(vehicleName); } } else { // Loading database for read-only DB.Culture currentCulture = Program.ApplicationSettings.GetCurrentCulture(); // Physics TduFile[] loadedFiles = DatabaseHelper.LoadTopicForReadOnly(DB.Topic.CarPhysicsData, currentCulture); DB physics = loadedFiles[0] as DB; DBResource rPhysics = loadedFiles[1] as DBResource; // Brands loadedFiles = DatabaseHelper.LoadTopicForReadOnly(DB.Topic.Brands, currentCulture); DB brands = loadedFiles[0] as DB; DBResource rBrands = loadedFiles[1] as DBResource; originalNamesByModdedNames = new Dictionary <string, string>(); foreach (KeyValuePair <string, string> anotherPair in VehicleSlotsHelper.SlotReference) { // Brand name string brandName = NamesHelper.GetVehicleBrandName(anotherPair.Value, physics, brands, rBrands); // Vehicle name string vehicleName = NamesHelper.GetVehicleFullName(anotherPair.Value, false, physics, rPhysics, brands, rBrands); string moddedName = (brandName.ToUpper() + " " + vehicleName).Trim(); // To maintain 2 identical names while (originalNamesByModdedNames.ContainsKey(moddedName)) { moddedName += _SYMBOL_PRIME; } originalNamesByModdedNames.Add(moddedName, anotherPair.Key); vehicleNames.Add(moddedName); } } // Reference browsing foreach (string vehicleName in vehicleNames) { ListViewItem li = new ListViewItem(vehicleName); // Group by brand (first word in fact) string currentBrand = vehicleName.Split(' ')[0]; ListViewGroup currentGroup = new ListViewGroup(currentBrand, currentBrand); if (!vehicleListView.Groups.Contains(currentGroup)) { vehicleListView.Groups.Add(currentGroup); } li.Group = vehicleListView.Groups[currentBrand]; // Computing vehicle name string slotName = null; if (_IsShowOriginalNames) { slotName = vehicleName; } else if (originalNamesByModdedNames != null && originalNamesByModdedNames.ContainsKey(vehicleName)) { slotName = originalNamesByModdedNames[vehicleName]; } if (slotName != null && VehicleSlotsHelper.SlotReference.ContainsKey(slotName)) { string vehicleRef = VehicleSlotsHelper.SlotReference[slotName]; // Tag li.Tag = vehicleRef; VehicleSlotsHelper.VehicleInfo currentInfo = VehicleSlotsHelper.VehicleInformation[vehicleRef]; // Non-moddable vehicles are faded // Image depending on car or bike type if (currentInfo.isBike) { if (currentInfo.isModdable) { li.ImageIndex = (int)_ImageIndex.Bike; } else { li.ImageIndex = (int)_ImageIndex.NonModdableBike; } } else { if (currentInfo.isModdable) { li.ImageIndex = (int)_ImageIndex.Car; } else { li.ImageIndex = (int)_ImageIndex.NonModdableCar; } } vehicleListView.Items.Add(li); } } Cursor = Cursors.Default; }