Ejemplo n.º 1
0
        public async Task <JsonResult> GeneralInfoPartialView(int id, ApiClientGeneralViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(false));
            }

            var client = _configurationDbContext.Clients.Find(id);

            if (client == null)
            {
                return(Json(false));
            }

            client.ClientName  = model.ClientName;
            client.Description = model.Description;
            client.ClientUri   = model.ClientUri;
            _configurationDbContext.Clients.Update(client);
            try
            {
                await _configurationDbContext.SaveChangesAsync();

                return(Json(true));
            }
            catch (Exception e)
            {
                _logger.LogError(e.Message);
                return(Json(false));
            }
        }
Ejemplo n.º 2
0
        //[ValidateAntiForgeryToken]
        public async Task <IActionResult> _GeneralInfo(int id, ApiClientGeneralViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            var client = ConfigurationDbContext.Clients.Find(id);

            if (client == null)
            {
                return(Json(false));
            }

            try
            {
                ConfigurationDbContext.Entry(client).CurrentValues.SetValues(model);
                await ConfigurationDbContext.SaveChangesAsync();

                return(Json(true));
            }
            catch (Exception e)
            {
                _logger.LogError(e.Message);
                return(Json(false));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Get general info about current application
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <IActionResult> GeneralInfoPartialView(int?id)
        {
            if (!id.HasValue)
            {
                return(NotFound());
            }

            var appClient = await _configurationDbContext.Clients.AsNoTracking().SingleOrDefaultAsync(x => x.Id == id);

            var model = new ApiClientGeneralViewModel
            {
                Id          = appClient.Id,
                ClientName  = appClient.ClientName,
                Description = appClient.Description,
                ClientUri   = appClient.ClientUri
            };

            return(PartialView("Partial/GeneralInfoPartialView", model));
        }