public async Task <APIResult> Get(int id)
 {
     return(new APIResult()
     {
         Result = 0,
         Data = await routerQueries.Get(id)
     });
 }
Exemple #2
0
        public override async Task <int> HandleCommand(UpdateCommand request, CancellationToken cancellationToken)
        {
            if (request.Router == null || request.Router.Id == 0 || string.IsNullOrEmpty(request.Router.Name))
            {
                throw new BusinessException("Router.NotExisted");
            }

            var router = await routerQueries.Get(request.Router.Id);

            if (router == null)
            {
                throw new BusinessException("Router.NotExisted");
            }

            var employee = await WebHelper.HttpGet <Employee>(GlobalConfiguration.APIGateWayURI, AppUrl.GetEmployeeByUser, request.LoginSession.AccessToken);

            if (employee == null)
            {
                throw new NotPermissionException();
            }
            var distribution = (await this.distributionQueries.GetsBySupervisor(employee.Id)).FirstOrDefault(d => d.Id == router.DistributionId);

            if (distribution == null)
            {
                throw new NotPermissionException();
            }

            router.Name             = request.Router.Name;
            router.CurrentLatitude  = request.Router.CurrentLatitude;
            router.CurrentLongitude = request.Router.CurrentLongitude;
            router.Radius           = request.Router.Radius;
            router.CountryId        = request.Router.CountryId;
            router.ProvinceId       = request.Router.ProvinceId;
            router = UpdateBuild(router, request.LoginSession);
            return(await routerRepository.Update(router));
        }