示例#1
0
        /// <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));
        }
示例#2
0
        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;
            }
        }
示例#3
0
        public async Task DeleteZoneAsync(ZoneDto ZoneDto)
        {
            var Zone = _mapper.Map <Zone>(ZoneDto);
            await _zoneService.RemoveZoneAsync(Zone);

            await _transactionManager.SaveAllAsync();
        }
示例#4
0
        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);
        }
示例#5
0
        /// <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);
        }
示例#6
0
        /// <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);
        }
示例#7
0
        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);
        }
示例#9
0
        //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);
        }
示例#11
0
        /// <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));
        }
示例#12
0
        //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);
        }
示例#13
0
        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();
        }
示例#14
0
        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);
        }
示例#16
0
        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!"));
            }
        }
示例#17
0
        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}";
            }
        }
示例#18
0
        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);
        }