示例#1
0
        public async Task <IActionResult> Index()
        {
            var currentUser = await _userManager.GetUserAsync(User);

            if (currentUser == null)
            {
                return(Challenge());
            }

            var jsonItems = await _jsonItemService.GetItemsAsync(currentUser);

            var model = new JsonViewModel()
            {
                Items = jsonItems
            };

            return(View(model));
        }
示例#2
0
        public JsonResult GetDistricts(int cityId)
        {
            var response = new JsonViewModel {
                status = HttpStatusCode.InternalServerError, message = GeneralMessages.Error
            };

            try
            {
                response.data    = _mapper.Map <List <DropDownViewModel> >(_dropDownService.GetDistricts(cityId));
                response.status  = HttpStatusCode.OK;
                response.message = GeneralMessages.Ok;
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
            }
            return(Json(response, JsonRequestBehavior.AllowGet));
        }
        public JsonResult GetMatchGroupeshByEventId(int eventId, string key = "")
        {
            var response = new JsonViewModel {
                status = HttpStatusCode.InternalServerError, message = GeneralMessages.Error
            };

            try
            {
                response.data    = _mapper.Map <List <DropDownViewModel> >(_dropDownService.GetMatchGroupes(eventId, key));
                response.status  = HttpStatusCode.OK;
                response.message = GeneralMessages.Ok;
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
            }

            return(Json(response, JsonRequestBehavior.AllowGet));
        }
        public JsonResult LastVersionCheck(int id, int major, int minor, int patch, int clientId)
        {
            var response = new JsonViewModel {
                status = HttpStatusCode.InternalServerError, message = GeneralMessages.Error
            };

            try
            {
                //response.data =
                var appVersion = _appVersionService.Find(new AppVersion {
                    ClientId = clientId
                }).Where(w => w.Id != id);

                foreach (var item in appVersion)
                {
                    if (item.Major > major)
                    {
                        response.data = true;
                    }
                    else if (item.Major == major && item.Minor > minor)
                    {
                        response.data = true;
                    }
                    else if (item.Minor == minor && item.Patch > patch)
                    {
                        response.data = true;
                    }
                    else
                    {
                        response.data = false;
                    }
                }

                response.status  = HttpStatusCode.OK;
                response.message = GeneralMessages.Ok;
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
            }
            return(Json(response, JsonRequestBehavior.AllowGet));
        }
示例#5
0
        public ActionResult GetReportsToCache()
        {
            var response = _lookupRepository.GetReportsToCache();

            var reportsKey = LookupType.Reports.ToString();
            var lookups    = response.DataItems.First();
            var reports    = new List <dynamic>();

            if (lookups.ContainsKey(reportsKey))
            {
                reports = lookups[reportsKey];
            }

            var lookupsViewModel = new JsonViewModel()
            {
                Json = String.Join(",", reports.Select(x => string.Format("'{0}': {1}", x.Name, x.Model)).ToArray())
            };

            Response.ContentType = "text/javascript";
            return(View(lookupsViewModel));
        }
    public ActionResult Index()
    {
        // 1. Perform HTTP request to retrieve the JSON.
        var    webClient = new WebClient();
        string rawJson   = webClient.DownloadString("json-url");

        // 2. Parse the JSON.
        var jsonRootObject = JsonConvert.DeserializeObject <JsonRootObject>(rawJson);

        // 3. Map to your viewmodel
        var viewModel = new JsonViewModel
        {
            Items = jsonRootObject.Items.Select(i => new JsonItem
            {
                Name = i.Name,
                Unit = i.Unit
            }).ToList()
        };

        // 4. Return the model to your view
        return(View(viewModel));
    }
示例#7
0
        void ShowSource_Click(object sender, RoutedEventArgs e)
        {
            JToken json = Source;

            if (json == null)
            {
                JsonViewModel jvm = AssociatedObject.DataContext as JsonViewModel;
                if (jvm != null && jvm.OriginalJsonValue != null)
                {
                    json = jvm.OriginalJsonValue;
                }
            }

            ViewModel vm = AssociatedObject.DataContext as ViewModel;

            if (json != null && vm != null)
            {
                vm.Publish(new MasonViewModel.SourceChangedEventArgs {
                    Source = (Prefix ?? "") + ": " + json.ToString()
                });
            }
        }
示例#8
0
        public ActionResult JsonModelBinder()
        {
            var viewModel = new JsonViewModel();

            return(this.View(viewModel));
        }
示例#9
0
 public ControllerBase()
 {
     _stopWatch  = new Stopwatch();
     _jsonResult = new JsonViewModel();
 }
示例#10
0
 internal async Task <JsonResult> Json(JsonViewModel JsonViewModel)
 {
     return(await Task.Factory.StartNew(() => Json(JsonViewModel, JsonRequestBehavior.AllowGet)));
 }
示例#11
0
 private static JsonResult toJsonUnAsync(this JsonViewModel JsonViewModel)
 {
     return(new JsonHelper().Json(JsonViewModel).Result);
 }
示例#12
0
 public static async Task <JsonResult> toJson(this JsonViewModel JsonViewModel)
 {
     return(await new JsonHelper().Json(JsonViewModel));
 }
        public void DeletePeople(JsonViewModel vm)
        {
            var db = new PeopleRepository(_conn);

            db.DeleteMany(vm.Ids);
        }
示例#14
0
 public IActionResult PostJson([FromBody] JsonViewModel request)
 {
     return(Json(new { Num = request.Num.Value, Text = request.Text.Value, }));
 }