public StreetDto GetStreetById(int streetId) { var sqlQuery = @"SELECT s.id,s.name,s.city_id,p.id as Prefix_id,p.Name as Prefix_Name,p.ShortName FROM CallCenter.Streets s join CallCenter.StreetPrefixes p on p.id = s.prefix_id where s.id = @StreetId and s.enabled = 1"; using (var cmd = new MySqlCommand(sqlQuery, _dbConnection)) { cmd.Parameters.AddWithValue("@StreetId", streetId); StreetDto street = null; using (var dataReader = cmd.ExecuteReader()) { if (dataReader.Read()) { street = new StreetDto { Id = dataReader.GetInt32("id"), Name = dataReader.GetString("name"), Prefix = new StreetPrefixDto { Id = dataReader.GetInt32("Prefix_id"), Name = dataReader.GetString("Prefix_Name"), ShortName = dataReader.GetString("ShortName") }, CityId = dataReader.GetInt32("city_id") }; } dataReader.Close(); } return(street); } }
private void RefreshHouses(StreetDto street) { HouseList.Clear(); if (street == null) { return; } RequestService.GetHouses(street.Id, SelectedCompany?.Id).ToList().ForEach(h => HouseList.Add(h)); }
public static Feature ParseStreetToFeature(StreetDto street) { var geometry = new LineString(street.Location); var properties = new Dictionary <string, dynamic> { { "Id", street.Id.ToString() }, { "Name", street.Name == null? "": street.Name.ToString() }, }; return(new Feature(geometry, properties)); }
private void ShowStreetEditDialog(StreetDto selectedItem) { var model = new StreetAdminDialogViewModel(RequestService, selectedItem?.Id); var view = new StreetAddOrEditDialog(); model.SetView(view); view.Owner = Application.Current.MainWindow; view.DataContext = model; if (view.ShowDialog() == true) { RefreshStreets(SelectedCity, SelectedCompany); } }
public virtual IActionResult GetItem([FromBody] int id) { StreetDto dto = service.GetById(id); if (dto == null) { return(BadRequest()); } StreetModel model = mapper.Map <StreetModel>(dto); return(Ok(model)); }
public virtual IActionResult UpdateItem([FromBody] StreetModel model) { if (model == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } StreetDto dto = mapper.Map <StreetDto>(model); service.Update(dto); return(Ok()); }
public IActionResult Post([FromBody] StreetDto dto) { var streetsRepository = _unitOfWork.StreetsRepository; if (streetsRepository.Exists(dto.LocalityId, dto.Name)) { return(BadRequest()); } var street = new Street { LocalityId = dto.LocalityId, Name = dto.Name }; streetsRepository.Add(street); _unitOfWork.Save(); return(Ok(_streetDtoMapper.Map(street))); }
public void Update(StreetDto subject) { streetService.Update(subject); }
public StreetDto Add(StreetDto subject) { return(streetService.Add(subject)); }
public void Add(StreetDto item) { _streetManager.Add(item); }
public void Update(StreetDto subject) { streetStorage.Update(subject); }
public StreetDto Add(StreetDto subject) { return(streetStorage.Add(subject)); }