Esempio n. 1
0
        public async Task <IActionResult> GetAsync(Guid id)
        {
            var data = await _service.GetAsync(id);

            data.ClientSecret = data.ClientSecret.ToBase64EncodeWithKey(_config["Security:EncryptKey"]);

            if (data == null)
            {
                _loger.LogError("Data not found for id : " + id.ToString());

                var error = new NotFound("Data not found for id : " + id.ToString(), new { id });
                return(error.ReturnResponse());
            }

            var result = new OK("Success get data by id = " + id.ToString(), data);

            return(result.ReturnResponse());
        }
Esempio n. 2
0
        public async Task <IActionResult> EditAsync(Guid id)
        {
            var result = await _service.GetAsync(id);

            if (result.StatusCode != (int)HttpStatusCode.OK)
            {
                Code    = result.StatusCode;
                Message = result.Message;
                return(RedirectToAction(nameof(Index)));
            }

            var model = new BaseApiResultViewModel <ClientApiViewModel>()
            {
                StatusCode = Code,
                Data       = result.Data,
                Message    = Message
            };

            return(View(model));
        }