public Boolean UpdateLastActiveDate(Guid userId, DateTimeOffset currentDate)
        {
            _logger.LogInfo($"Supplier method '{nameof(UpdateLastActiveDate)}({userId}, {currentDate})' is called");

            CLastActiveDateDto lastActive = new CLastActiveDateDto(userId, currentDate);

            return(_service.UpdateLastActiveDate(lastActive));
        }
        public IHttpActionResult UpdateLastActiveDate([FromBody] CLastActiveDateDto lastActiveDate)
        {
            s_log.LogInfo($"{System.Reflection.MethodBase.GetCurrentMethod()}({lastActiveDate}) is called");

            if (lastActiveDate == null)
            {
                s_log.LogError($"{System.Reflection.MethodBase.GetCurrentMethod()}({(CLastActiveDateDto)null})", new ArgumentNullException(nameof(lastActiveDate), "Incoming data is null"));
                ModelState.AddModelError($"{nameof(lastActiveDate)}", "Incoming data is null");
                return(BadRequest(ModelState));
            }

            Int32 result = _userDataProvider.UpdateUserLastActiveDate(lastActiveDate.UserId, lastActiveDate.LastActiveDate);

            if (result == 0)
            {
                s_log.LogError($"{System.Reflection.MethodBase.GetCurrentMethod()}({lastActiveDate})", new Exception("Failed to update user last active date"));
                return(NotFound());
            }

            return(Ok(true));
        }
예제 #3
0
        public Boolean UpdateLastActiveDate(CLastActiveDateDto lastActiveDate)
        {
            Console.WriteLine($@"Service method '{nameof(UpdateLastActiveDate)}({lastActiveDate})' is called");
            _logger.LogInfo($"Service method '{nameof(UpdateLastActiveDate)}({lastActiveDate})' is called");
            try
            {
                HttpResponseMessage response = _client.PostAsync(
                    //$"api/user/{userId}/lastActive?lastActiveDate={currentDate}"
                    //$"api/user/{userId}/lastActive?lastActiveDate={System.Net.WebUtility.UrlEncode(currentDate.ToString(System.Globalization.CultureInfo.InvariantCulture))}"
                    $"api/user/lastActiveDate",
                    new StringContent(JsonConvert.SerializeObject(lastActiveDate), Encoding.UTF8, "application/json")
                    ).Result;

                return((response.IsSuccessStatusCode)
                    ? response.Content.ReadAsAsync <Boolean>().Result
                    : false);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }