public Region Edit(Region region) { try { connection.Open(); var cmd = connection.CreateCommand() as SqlCommand; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "Region_Edit"; cmd.Parameters.Add(new SqlParameter("@Name", region.Name)); cmd.Parameters.Add(new SqlParameter("@CountryCode", !string.IsNullOrWhiteSpace(region.CountryCode)? region.CountryCode : "AR")); cmd.Parameters.Add(new SqlParameter("@LowThreshold", region.LowThreshold)); cmd.Parameters.Add(new SqlParameter("@HighThreshold", region.HighThreshold)); cmd.Parameters.Add(new SqlParameter("@NormalPoints", region.NormalPoints)); cmd.Parameters.Add(new SqlParameter("@BonusPoints", region.BonusPoints)); cmd.Parameters.Add(new SqlParameter("@PenaltyPoints", region.PenaltyPoints)); cmd.Parameters.Add(new SqlParameter("@Id", region.Id)); cmd.ExecuteNonQuery(); connection.Close(); return region; } catch (Exception ex) { throw ex; } }
public HttpResponseMessage<Region> Edit(Region region, HttpRequestMessage<Region> request) { if (region != null) { var basecampDb = regionRepository.Edit(region); var response = new HttpResponseMessage<Region>(basecampDb) { StatusCode = HttpStatusCode.Created }; return response; } return new HttpResponseMessage<Region>(null) { StatusCode = HttpStatusCode.NotFound, }; }
private void regionsCombo_SelectionChanged(object sender, SelectionChangedEventArgs e) { var c = sender as ComboBox; //Si es la primera vez que inicializa, le cargo el valor default (seleccionar region) if (Convert.ToInt32(c.SelectedValue) == null) { _selectedRegionId = 0; } else { _selectedRegionId = Convert.ToInt32(c.SelectedValue); } _selectedRegion = _allRegionsForSelectedCountry.Where(r => r.Id == _selectedRegionId).FirstOrDefault(); }
void regionRequests_RegionsReceived(object sender, EventArgs e) { _allRegionsForSelectedCountry = sender as List<Region>; //Recibo todas las regiones para ese pais, asi cargo el combo if (_allRegionsForSelectedCountry.Count > 1) { //Inicializacion de variables var selectRegionOption = new Region(0, Labels.SelectRegion, _allRegionsForSelectedCountry.First().CountryCode); _allRegionsForSelectedCountry.Add(selectRegionOption); _selectedRegion = null; this.regionsCombo.ItemsSource = _allRegionsForSelectedCountry; this.regionsCombo.SelectedValue = selectRegionOption.Id; this.Regions.Visibility = Visibility.Visible; this.nextButton.IsEnabled = true; } else { this.Regions.Visibility = Visibility.Collapsed; _selectedRegion = _allRegionsForSelectedCountry.FirstOrDefault(); this.nextButton.IsEnabled = true; } }
private void mapImage_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { try { Color color = GetColorFromImage(e); MapCountry mapCountry = GetCountryByColor(color); if (mapCountry != null) { _selectedCountry = mapCountry; this.nextButton.IsEnabled = true; this.txtSelectedCountry.Text = mapCountry.GetDescription(); this.mapImage.Source = mapCountry.GetMapImage(); this.refColor.Visibility = System.Windows.Visibility.Visible; this.refColor.Fill = new SolidColorBrush(mapCountry.GetSecondaryColor()); } if (_selectedCountry != null) { if(_selectedCountry.IsOwnCode("AR")) //HACK, Como siempre es argentina, hardcodeo las regiones y sus Ids { _allRegionsForSelectedCountry = new List<Region>(); //Inicializacion de variables var selectRegionOption = new Region(0, Labels.SelectRegion, "AR"); var saltaRegionOption = new Region(1, "Salta", "AR"); var chacoRegionOption = new Region(2, "Chaco", "AR"); _allRegionsForSelectedCountry.Add(selectRegionOption); _allRegionsForSelectedCountry.Add(saltaRegionOption); _allRegionsForSelectedCountry.Add(chacoRegionOption); this.regionsCombo.ItemsSource = _allRegionsForSelectedCountry; this.regionsCombo.SelectedValue = selectRegionOption.Id; this.Regions.Visibility = Visibility.Visible; this.nextButton.IsEnabled = true; } else { regionRequests.GetRegionsByCountryCode(_selectedCountry.GetCode()); this.nextButton.IsEnabled = false; } } } catch(Exception ex) { throw ex; } }
public HttpResponseMessage<Region> Post(Region region, HttpRequestMessage<Region> request) { if (region != null) { var regionDB = regionRepository.Insert(region); var response = new HttpResponseMessage<Region>(regionDB) { StatusCode = HttpStatusCode.Created }; return response; } return new HttpResponseMessage<Region>(null) { StatusCode = HttpStatusCode.NotFound, }; }
private int SetPrecisionScore(decimal? precision, Region region) { if (precision != null && precision >= region.HighThreshold) return region.BonusPoints; else if (precision != null && precision <= region.LowThreshold) return region.PenaltyPoints; else return region.NormalPoints; }