public async Task <IActionResult> UpdateTimeZoneAsync([FromBody] TimeZoneContract timeZone)
        {
            if (timeZone == null)
            {
                return(Error("Invalid Payload"));
            }
            else if (timeZone.Id < 1)
            {
                return(Error("Invalid time zone id"));
            }
            else if (string.IsNullOrWhiteSpace(timeZone.Name))
            {
                return(Error("Invalid time zone name"));
            }

            _logger.LogInformation($"Updating time zone: ${timeZone.Id}");

            var command = new AddOrUpdateTimeZoneCommand
            {
                TimeZone = timeZone,
                UserId   = GetUserIdFromClaim()
            };
            var result = await _messages.Dispatch(command).ConfigureAwait(false);

            return(Ok(result));
        }
示例#2
0
        public async Task <int> AddOrUpdateTimeZoneAsync(TimeZoneContract timeZone, int userId)
        {
            using var connection = _connectionFactory.GetDbConnection();
            var procName = StoredProcedureConstants.UpsertTimeZone;
            var result   = await connection.QueryAsync <int>(procName, new
            {
                timeZone.Id,
                timeZone.Name,
                timeZone.Description,
                timeZone.Hours,
                UserId = userId,
                timeZone.Active
            }, null, null, CommandType.StoredProcedure).ConfigureAwait(false);

            return(result.FirstOrDefault());
        }