/// <summary> /// Update zone Detail asynchronously /// </summary> /// <param name="uuid">The uuid of the zone</param> /// <param name="zone">the zone data </param> /// <returns>an error code and the json response</returns> public async Task <ApiResponse> UpdateDetailAsync(string uuid, ZoneDto zone) { StringContent content = new StringContent(JsonConvert.SerializeObject(zone), Encoding.Default, "application/json"); string request = "zones/" + uuid; return(await RequestPatchAsync(request, content)); }
private async void OnSelectZone(ZoneDto obj) { if (IsBusy) { return; } IsBusy = true; try { // Thuc hien cong viec tai day var selectedZone = ListZoneBindProp.FindFirst(z => z.IsSelected); if (selectedZone != null) { selectedZone.IsSelected = false; } obj.IsSelected = true; CurrentZone = obj; ZoneFrameVisibleBindProp = true; ListInvoiceFrameVisibleBindProp = false; } catch (Exception e) { await ShowErrorAsync(e); } finally { IsBusy = false; } }
public async Task DeleteZoneAsync(ZoneDto ZoneDto) { var Zone = _mapper.Map <Zone>(ZoneDto); await _zoneService.RemoveZoneAsync(Zone); await _transactionManager.SaveAllAsync(); }
public IEnumerable <Zone> GetAllChildZones(int zoneId) { List <Zone> zones = new List <Zone>(); ZoneDto zoneDto = _zoneDao.GetZoneById(zoneId); if (zoneDto == null) { return(new List <Zone>()); } zones.Add(Zone.FromDto(zoneDto)); List <int> zonesToLookUp = new List <int>(zones.Select(x => x.Id)); while (true) { var newZones = _zoneDao.GetAllActiveChildZones(zonesToLookUp).ToList(); if (!newZones.Any()) { break; } zones.AddRange(newZones.Select(Zone.FromDto)); zonesToLookUp = newZones.Select(x => x.Id).ToList(); } return(zones); }
/// <summary> /// Update zone Detail asynchronously /// </summary> /// <param name="uuid">The uuid of the zone</param> /// <param name="zone">the zone data </param> /// <returns>an error code and the json response</returns> public async Task <ZoneUpdateResponse> UpdateDetailAsync(string uuid, ZoneDto zone) { ApiResponse resp = await _client.UpdateDetailAsync(uuid, zone); ZoneUpdateResponse retour = new ZoneUpdateResponse(); retour.Load(resp); return(retour); }
/// <summary> /// Create a zone asynchronously /// </summary> /// <param name="zone">Content to create zone</param> /// <param name="sharingId">Sharing_id if need</param> /// <returns>an error code and the json response</returns> public async Task <ZoneCreateResponse> CreateAsync(ZoneDto zone, string sharingId = null) { ApiResponse resp = await _client.CreateAsync(zone, sharingId); ZoneCreateResponse retour = new ZoneCreateResponse(); retour.Load(resp); return(retour); }
public async Task <ZoneDto> UpdateZoneAsync(ZoneDto ZoneDto) { var Zone = _mapper.Map <Zone>(ZoneDto); await _zoneService.UpdateZoneAsync(Zone); await _transactionManager.SaveAllAsync(); return(_mapper.Map <ZoneDto>(Zone)); }
public void TestUpdate_NoName() { //Get valid zone ZoneDto zone = GetZone(); zone.Name = null; zone.Description = "Test Edit"; _controller.Update(zone); }
//update zone public async Task UpdateZone(ZoneDto input) { // here aoutomapping can be done; var zone = _zoneRepository.FirstOrDefault(input.Id); zone.Description = input.Description; zone.Name = input.Name; await _zoneRepository.UpdateAsync(zone); }
public void TestUpdate_EmptyName() { //Get valid zone ZoneDto zone = GetZone(); zone.Name = string.Empty; zone.Description = "Test Edit"; _controller.Update(zone); }
/// <summary> /// Create a zone asynchronously /// </summary> /// <param name="toCreate">Zone data to create</param> /// <param name="sharingId">Sharing_id if need</param> /// <returns>an error code and the json response</returns> public async Task <ApiResponse> CreateAsync(ZoneDto toCreate, string sharingId = null) { StringContent content = new StringContent(JsonConvert.SerializeObject(toCreate), Encoding.Default, "application/json"); string request = "zones"; if (!string.IsNullOrEmpty(sharingId)) { request += "?sharing_id=" + sharingId; } return(await RequestPostAsync(request, content)); }
//delete zone public async Task DeleteZoneAsync(ZoneDto input) { var zone = _zoneRepository.FirstOrDefault(input.Id); if (zone == null) { throw new UserFriendlyException("Zone not Found!"); } await _zoneRepository.DeleteAsync(zone); }
public void UpdateZone(ZoneDto zoneDto) { var zones = this.iZoneDataService.GetZone(zoneDto.ID); zones.ID = zoneDto.ID; zones.SupplierBaseID = zoneDto.SupplierBaseID; zones.Name = zoneDto.Name; zones.Description = zoneDto.Description; this.iZoneDataService.SaveChanges(); }
public void AddZone(ZoneDto value) { var zone = new Zone(); zone.ID = value.ID; zone.SupplierBaseID = value.SupplierBaseID; zone.Name = value.Name; zone.Description = value.Description; this.iZoneDataService.AddZone(zone); }
public void TestGetById_ValidId() { //Get a valid zone ZoneDto validZone = GetZone(); //Try to get this zone ZoneDto zoneResult = _controller.GetById(validZone.Id); Assert.IsNotNull(zoneResult); Assert.IsNotNull(zoneResult.Id); Assert.AreEqual(validZone.Id, zoneResult.Id); }
public async Task <IActionResult> UpdateZone(ZoneDto zoneDto) { var ok = await _mediator.Send(new UpdateZoneCommand(zoneDto)); if (ok) { return(NoContent()); } else { return(BadRequest("Không thể cập nhật khu vực!")); } }
protected override async Task OnInitializedAsync() { Saved = false; int.TryParse(ZoneId, out var zoneId); if (zoneId != 0)//new zone is being created { ZoneDto = await ZoneDataService.GetZoneById(zoneId); Zone = Mapper.Map <ZoneForUpdateDto>(ZoneDto); Title = $"Details for {Zone.Description}"; } }
public async Task <IActionResult> CreateZone(ZoneDto zoneDto) { var zoneToReturn = await _mediator.Send(new AddZoneCommand(zoneDto)); if (zoneToReturn != null) { return(CreatedAtRoute(nameof(GetZone), new { id = zoneToReturn.Id }, zoneToReturn)); } else { return(BadRequest("Không thể tạo mới!")); } }
public void TestUpdate_InvalidId() { //Get valid zone ZoneDto zone = GetZone(); ZoneDto updatedZone = new ZoneDto() { Id = 0, Name = zone.Name, Description = zone.Description }; _controller.Update(updatedZone); }