private void SearchAllArea() { _allAreaDtoList.Clear(); DataSet ds = webService.SearchArea(""); if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { AreaDto area = new AreaDto(); area.AreaCode = Convert.ToString(ds.Tables[0].Rows[i]["AreaCode"]); area.AreaName = Convert.ToString(ds.Tables[0].Rows[i]["AreaName"]); area.UpperAreaCode = Convert.ToString(ds.Tables[0].Rows[i]["UpperAreaCode"]); area.AreaTypeCode = Convert.ToString(ds.Tables[0].Rows[i]["AreaTypeCode"]); _allAreaDtoList.Add(area); } } //设置全局变量 _saleBigAreaDtoList = (from x in _allAreaDtoList where x.AreaTypeCode == "01" select x).ToList <AreaDto>(); _saleSmallAreaDtoList = (from x in _allAreaDtoList where x.AreaTypeCode == "02" select x).ToList <AreaDto>(); _afterBigAreaDtoList = (from x in _allAreaDtoList where x.AreaTypeCode == "03" select x).ToList <AreaDto>(); _afterSmallAreaDtoList = (from x in _allAreaDtoList where x.AreaTypeCode == "04" select x).ToList <AreaDto>(); //添加‘全部’选项 _saleBigAreaDtoList.Insert(0, new AreaDto("", "全部", "", "01")); _afterBigAreaDtoList.Insert(0, new AreaDto("", "全部", "", "01")); }
/// <summary> /// 转换为地区实体 /// </summary> /// <param name="dto">地区数据传输对象</param> public static Area ToEntity(this AreaDto dto) { if (dto == null) { return(new Area()); } return(new Area(dto.Id.ToGuid(), dto.Id, 1) { Name = dto.Name, AdministrativeRegion = dto.AdministrativeRegion.SafeValue(), TelCode = dto.TelCode, ZipCode = dto.ZipCode, Longitude = dto.Longitude, Latitude = dto.Latitude, ParentId = dto.ParentId.ToGuidOrNull(), Enabled = dto.Enabled.SafeValue(), SortId = dto.SortId, PinYin = dto.PinYin, FullPinYin = dto.FullPinYin, CreationTime = dto.CreationTime, CreatorId = dto.CreatorId, LastModificationTime = dto.LastModificationTime, LastModifierId = dto.LastModifierId, IsDeleted = dto.IsDeleted.SafeValue(), Version = dto.Version, }); }
public IActionResult Edit(int id, AreaDto areaDto) { logger.Info(nameof(AreasController.Edit)); if (id != areaDto.Id) { logger.Warn(nameof(AreasController.Edit) + " id is not equal to area.Id"); return(NotFound()); } if (ModelState.IsValid) { try { areaService.Update(areaDto); } catch (Exception exception) { logger.Error(exception); return(BadRequest()); } } return(RedirectToAction(nameof(Index))); }
private void OnSelectionChanged(object sender, EventArgs e) { if (changingSource) { return; } ListBox list = (ListBox)sender; AreaDto selectedItem = GetSelectedArea(list); if (selectedItem == null) { return; } switch (selectedItem.Type) { case Enum.AreaType.World: ListSessions.SelectedItem = null; break; case Enum.AreaType.Session: ListMaps.SelectedItem = null; break; } if (selectedItem.Type == Enum.AreaType.Session) { if (!selectedItem.MatchingAreas.Any()) { selectedItem.MatchingAreas = WorldController.Instance.GetKnownAreas(selectedItem); } Debug.WriteLine(String.Format("Area '{0}' matches {1} times", selectedItem.Name, selectedItem.MatchingAreas.Count)); } Canvas.SetArea(selectedItem); }
//获取所有的大区信息 public static List <AreaDto> GetAllArea() { //CommonHandler.DBConnect(); List <AreaDto> areaList = new List <AreaDto>(); //string sql = string.Format("SELECT AreaCode,AreaName FROM Area"); DataSet ds = null; if (IsNetWork) { ds = webService.GetAllArea(); } else { localService.Url = "http://192.168.1.99/XHX.YiQiServer/service.asmx"; ds = localService.GetAllArea(); } if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { AreaDto area = new AreaDto(); area.AreaCode = Convert.ToString(ds.Tables[0].Rows[i]["AreaCode"]); area.AreaName = Convert.ToString(ds.Tables[0].Rows[i]["AreaName"]); areaList.Add(area); } } return(areaList); }
/// <summary> /// 转换为地区实体 /// </summary> /// <param name="dto">地区数据传输对象</param> public static Area ToEntity(this AreaDto dto) { if (dto == null) { return(new Area()); } return(dto.MapTo(new Area(dto.Id.ToGuid(), "", 1))); }
private static Area MapToArea(AreaDto area) => area == null ? null : new Area { AreaType = area.Type, AreaId = area.Id };
static void Main(string[] args) { var utils = new DataUtils(); var init = new InitData(); var efUtils = new EFUtils(); var users = init.GetUsers(10000); //DateTime strtime = DateTime.Now; //for (int i = 0; i < 10000; i++) //{ // utils.Add(init.GetUser()); //} //DateTime endtime = DateTime.Now; //Console.WriteLine($"dapper添加10000个用户:{endtime - strtime}"); //DateTime efstrtime = DateTime.Now; //for (int i = 0; i < 10000; i++) //{ // efUtils.Add(init.GetUser()); //} //DateTime efendTime = DateTime.Now; //Console.WriteLine($"EF添加10000个用户:{efendTime - efstrtime}"); //DateTime strtime = DateTime.Now; //utils.AddRange(users); //DateTime endtime = DateTime.Now; //Console.WriteLine($"dapper批量添加10000个用户:{endtime - strtime}"); //var users2 = init.GetUsers(10000); //DateTime efstrtime = DateTime.Now; //efUtils.AddRange(users2); //DateTime efendtime = DateTime.Now; //Console.WriteLine($"EF批量添加10000个用户:{efendtime - efstrtime}"); //utils.InitArea(); //DateTime dpselectStrTime = DateTime.Now; //for (int i = 0; i < 1000; i++) //{ // var area = utils.SelectAreaByCode("130500"); //} //DateTime dpselectEndTime = DateTime.Now; //DateTime efselectStrTime = DateTime.Now; //for (int i = 0; i < 1000; i++) //{ // var area = efUtils.LinqSelectArea("130500"); //} //DateTime efselectEndTime = DateTime.Now; //Console.WriteLine($"dapper查询1000次:{dpselectEndTime - dpselectStrTime}"); //Console.WriteLine($"EF查询1000次:{efselectEndTime - efselectStrTime}"); SortedDictionary <string, string> sort = new SortedDictionary <string, string>(); object dto = new AreaDto { Name = "woshiceshi", pName = "ceshishsishi" }; Type type = dto.GetType(); var ts = type.GetProperties(); Console.ReadKey(); }
public Task <bool> UpdateArea(AreaDto request) { ValidationFields(request); var updateArea = _areaRepo .SearchMatching <AreaEntity>(d => d.AreaId == request.AreaId).FirstOrDefault(); var response = _areaRepo.Update(_mapper.Map <AreaEntity>(updateArea)); return(Task.FromResult(response)); }
public async Task <AreaResponseDto> AreaManagementInsert(AreaDto requestDto) { var result = await _areaService.AddArea(requestDto).ConfigureAwait(false); return(new AreaResponseDto { StatusCode = result != default ? HttpStatusCode.OK : HttpStatusCode.Unauthorized, StatusDescription = result != default? "Ok":"Error", });
private void AddShape(AreaDto area, Guid areaId, Guid shapId, AreaMapBulk bulk) { bulk.Shape.Add(new Shape() { Id = shapId, TypeId = area.Shape.Type, AreaId = areaId }); }
public void CreateArea_WhenModelNotValid_ShouldReturnArgumentException() { var area = new AreaDto { Description = null, CoordX = 10, CoordY = 20, LayoutId = 1 }; Assert.Throws <ArgumentException>(() => _venueService.CreateArea(area)); }
public void CreateArea_WhenAreaDescriptionExists_ShouldReturnValidationException() { var area = new AreaDto { Description = "Description", CoordX = 10, CoordY = 20, LayoutId = 1 }; Assert.Throws <ValidationException>(() => _venueService.CreateArea(area)); }
public Task <AreaDto> SearchAreaById(AreaDto request) { ValidationFields(request); var areaIdExist = _areaRepo .SearchMatching <AreaEntity>(id => id.AreaId == request.AreaId).FirstOrDefault(); return(Task.FromResult(_mapper.Map <AreaDto>(areaIdExist))); }
private void grvArea_ShowingEditor(object sender, CancelEventArgs e) { AreaDto area = grvArea.GetRow(grvArea.FocusedRowHandle) as AreaDto; if (area.StatusType != 'I') { e.Cancel = true; } }
public void AddAreas(AreaDto areaDto) { Area area = new Area(); area.Nombre = areaDto.Nombre; area.Descripcion = areaDto.Descripcion; area.CiudadId = areaDto.CiudadId; areasRepo.Add(area); }
private void ValidationAreIdExist(AreaDto request) { var areaIdExist = _repoArea.SearchMatching <AreaEntity>(a => a.AreaId == request.AreaId).Any(); if (!areaIdExist) { throw new DontExistIdException(); } }
public async Task <IHttpActionResult> CreateArea(AreaDto areaDto) { var areaDtoValidator = validatorFactory.GetValidator <AreaDto>(); await areaDtoValidator.ValidateAndThrowAsync(areaDto); var apiResult = await areaManager.CreateAreaAsync(areaDto); return(Ok(apiResult)); }
public static Area MapToArea(AreaDto from) { return(new Area { CoordX = from.CoordX, CoordY = from.CoordY, Description = from.Description, LayoutId = from.LayoutId }); }
public int CreateArea(AreaDto area) { ModelValidation.IsValidModel(area); if (IsAreaExist(area)) { throw new ValidationException("Area can't be created with this description"); } return(_areaRepository.Add(_mapper.Map <Area>(area))); }
// GET: api/Area/5 public AreaDto Get(int id) { Area item = _manager.GetById(id); AreaDto result = new AreaDto(); result.Id = item.Id; result.Code = item.Code; result.Name = item.Name; result.Description = item.Description; return(result); }
public void CreateArea_WhenModelValid_ShouldReturnNewId() { var area = new AreaDto { Description = "new Description", CoordX = 10, CoordY = 20, LayoutId = 1, Price = 100 }; var result = _venueService.CreateArea(area); Assert.AreEqual(result, ReturnIdArea); }
protected void OnToolSessionMerge(Object sender, EventArgs ev) { AreaDto sourceArea = GetSelectedSession(); if (sourceArea == null) { MessageBox.Show("select a area to merge, first!"); return; } AreaDto targetArea = null; if (!sourceArea.MatchingAreas.Any()) { sourceArea.MatchingAreas = WorldController.Instance.GetKnownAreas(sourceArea); } if (sourceArea.MatchingAreas.Any()) { try { targetArea = sourceArea.MatchingAreas.OrderByDescending(a => (a.Score.HasValue) ? a.Score : 0).First(); } catch (Exception e) { Debug.WriteLine(this.GetType().Name + ": " + e); } } List <AreaDto> targetAreas = new(sourceArea.MatchingAreas); foreach (var map in WorldController.Instance.AreaList) { if (!targetAreas.Contains(map)) { targetAreas.Add(map); } } MergeForm form = new(sourceArea, targetAreas); var result = form.ShowDialog(); switch (result) { case DialogResult.OK: case DialogResult.Yes: WorldController.Instance.Merge(form.SourceArea, form.TargetArea, form.Offset); break; case DialogResult.None: case DialogResult.Cancel: case DialogResult.Abort: case DialogResult.Retry: case DialogResult.Ignore: case DialogResult.No: default: break; } }
/// <summary> /// 更新 /// </summary> /// <param name="dto">模型</param> /// <returns></returns> public async Task <bool> Update(AreaDto dto) { var entity = await _context.Areas.FindAsync(dto.Id); entity.Name = dto.Name; entity.SimpleSpelling = dto.SimpleSpelling; entity.FullSpelling = dto.FullSpelling; await _context.SaveChangesAsync(); return(true); }
private static Area ConvertToEntity(AreaDto obj) { return(new Area { Id = obj.Id, Description = obj.Description, CoordX = obj.CoordX, CoordY = obj.CoordY, TMLayoutId = obj.TMLayoutId, }); }
/// <summary> /// From Area dto To Area pivot. /// </summary> /// <param name="areaDto">area dto to assemble.</param> /// <returns>Areapivot result.</returns> public static AreaPivot ToPivot(this AreaDto areaDto) { if (areaDto == null) { return(null); } return(new AreaPivot { AreaId = areaDto.AreaId, }); }
private void AddArea(AreaDto area, Guid areaId, Guid shapId, AreaMapBulk bulk) { bulk.Area.Add( new Domain.Entities.Area() { Id = areaId, Name = area.Name, ShapeId = shapId, Deleted = area.Deleted }); }
protected void OnAreaChanged(Object sender, EventArgs ev) { AreaDto area = (AreaDto)ComboBoxAreas.SelectedItem; CanvasOther.SetArea(area); CanvasThis.SelectedTile = new(); if (area.Offset.HasValue) { CanvasOther.SelectedTile = area.Offset.Value; } CalculateMerged(); }
public static Area ToAreaContract(AreaDto from) { return(new Area { SeatList = from.SeatList?.Select(x => SeatParser.ToSeatContract(x)).ToList(), CoordX = from.CoordX, CoordY = from.CoordY, Description = from.Description, Id = from.Id, LayoutId = from.LayoutId }); }
public AreaDto CreateArea(AreaDto area, List <SeatDto> seats) { area = _areaService.CreateArea(area); if (area.Id > 0) { seats.ForEach(s => s.AreaId = area.Id); seats.ForEach(s => s.Id = _seatService.CreateSeat(s).Id); } return(area); }