private async Task Login()
        {
            var response = await Service.Login(this);

            if (response.IsSuccessStatusCode)
            {
                var Token = await response.Content.ReadAsStringAsync();

                var service = new EnergyMetersService(Token);
                var meters  = await service.GetAll();

                await Navigation.PushAsync(new MainView(new MainViewModel(service, meters)));
            }
        }
        public async Task <IActionResult> GetAll()
        {
            var jwt = JwtService.GetJwt(HttpContext);

            if (jwt != null)
            {
                ViewBag.Jwt = jwt.Replace("\"", string.Empty).Trim();
                EnergyMetersService service = new EnergyMetersService(jwt);
                var meters = await service.GetAll(jwt);

                return(View(meters));
            }
            else
            {
                return(RedirectToRoute(new { controller = "Account", action = "Login" }));
            }
        }
Example #3
0
        private async Task Create()
        {
            var list = new List <MeterOfPoleDto>();

            foreach (var item in this.MetersOfPole)
            {
                list.Add(new MeterOfPoleDto {
                    meterSerialId = item.MeterId
                });
            }
            var dto      = new EnergyMeterCreateDto(this.SerialId, list, this.SelectType);
            var response = await Service.Create(dto);

            if (response.IsSuccessStatusCode)
            {
                var meters = await Service.GetAll();

                await Navigation.PushAsync(new MainView(new MainViewModel(Service, meters)));
            }
        }