public LoggedDeviceEntity GetByID(string uniq) { LoggedDeviceEntity result = null; using (SqlConnection connection = new SqlConnection(Connection.String)) { SqlCommand command = connection.CreateCommand(); command.CommandType = CommandType.StoredProcedure; command.CommandText = "LoginDeviceHistoryFindByID"; command.Parameters.Add(new SqlParameter("@PublicID", uniq)); connection.Open(); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { result = MapEntity(reader); } } } return(result); }
private LoggedDeviceEntity MapEntity(SqlDataReader data) { LoggedDeviceEntity result = new LoggedDeviceEntity(); result.Id = int.Parse(data["Id"].ToString()); result.ProfileID = data["PublicID"].ToString(); result.DeviceID = data["DeviceID"].ToString(); result.Date = DateTime.Parse(data["Date"].ToString()); return(result); }
public async Task <bool> Create(LoggedDeviceEntity entity) { using (SqlConnection connection = new SqlConnection(Connection.String)) { SqlCommand command = connection.CreateCommand(); command.CommandType = CommandType.StoredProcedure; command.CommandText = "LoginDeviceHistoryCreate"; command.Parameters.Add(new SqlParameter("@UserID", entity.ProfileID)); command.Parameters.Add(new SqlParameter("@DeviceID", entity.DeviceID)); connection.Open(); int result = (int)command.ExecuteNonQuery(); return(result == 1 ? true : false); } }
public ResponseMessage Create(LoggedDeviceEntity model, string identity) { ResponseMessage response = new ResponseMessage(); try { model.ProfileID = identity; response.IsSuccess = _loginDeviceHistoryRepository.Create(model).Result; } catch (Exception ex) { response.IsSuccess = false; response.ErrorMessage = ex.Message; } return(response); }
public ResponseMessage Create(LoggedDeviceEntity model, User user) { ResponseMessage response = new ResponseMessage(); try { if (user == null) { throw new UnauthorizedAccessException("Unauthorized!"); } model.ProfileID = user.PublicID; response.IsSuccess = _loginDeviceHistoryRepository.Create(model).Result; } catch (Exception ex) { response.IsSuccess = false; response.ErrorMessage = ex.Message; } return(response); }
private async Task RecordDeviceLoggedInFrom(LoggedDeviceEntity userAgent, User user) { userAgent.ProfileID = user.PublicID; await _auditRepository.Create(userAgent); }